akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int h, w;
    cin >> h >> w;

    int k[2000] = {}, m[2000] = {};
    int r = 0;

    for (int i = 0; i < h; i++) {
        char s[2001];
        cin >> s;

        int l = 0;
        for (int j = 0; j < w; j++) {
            if (s[j] == '.') {
                if (l == 0) {
                    int t = j + 1;
                    while (t < w && s[t] == '.') t++;
                    l = t - j;
                }
                k[j]++;
                m[j] = max(m[j], l);

            } else {
                r = max(r, k[j] + m[j]);
                l = 0;
                k[j] = 0;
                m[j] = 0;
            }
        }
    }
    for (int j = 0; j < w; j++) {
        r = max(r, k[j] + m[j]);
    }

    cout << r - 1 << endl;

    return 0;
}

Measured memory_bytes: 256
m = 1000000007
n, a, b = map(int, input().split())

def comb(n, r, m):
  X, Y = 1, 1
  for i in range(r):
    X *= n-i
    Y *= i+1
    X %= m
    Y %= m
  return int(X * pow(Y, m-2, m))

out = pow(2, n, m) - 1 - comb(n, a, m) - comb(n, b, m)
print(out%m)

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

using P = pair<int, int>;

int main() {
    int N;  cin >> N;
    vector<P> inc, dec, keep;
    for (int i = 0; i < N; ++i) {
        string s;  cin >> s;
        int now = 0, lowest = 0, end;
        for (int j = 0; j < s.size(); ++j) {
            if (s[j] == '(') ++now;
            else --now;
            end = now;
            lowest = min(lowest, now);
        }
        if (end > 0) inc.push_back(P(lowest, end));
        else if (end < 0) dec.push_back(P(lowest - end, end));
        else if (end == 0) keep.push_back(P(lowest, end));
    }

    sort(inc.begin(), inc.end(), greater<P>());
    sort(dec.begin(), dec.end());

    // DUMP(inc, keep, dec);

    int now = 0;
    for (P e : inc) {
        int lowest = now + e.first;
        if (lowest < 0) {
            cout << "No" << endl;
            return 0;
        }
        now += e.second;
    }
    for (P e : keep) {
        int lowest = now + e.first;
        if (lowest < 0) {
            cout << "No" << endl;
            return 0;
        }
        now += e.second;
    }
    for (P e : dec) {
        int lowest = now + e.second + e.first;
        if (lowest < 0) {
            cout << "No" << endl;
            return 0;
        }
        now += e.second;
    }
    if (now == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 11224
#include <cstdio>


int a, b, c;

int main(){
    scanf("%d %d %d", &a, &b, &c);

    if(a == b && b == c) printf("1\n");
    else if(a == b || b == c || a == c) printf("2\n");
    else printf("3\n");

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{   int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;++i){
        cin>>a.at(i);
    }
    reverse(a.begin(),a.end());
 cout<<a.at(0);
 for(int i=1;i<n;++i){
 cout<<" "<<a.at(i);
     
 }
 cout<<endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/



Measured memory_bytes: 3072
#include <stdio.h>

int main(void)
{
	int a, b;
	int i;
	int ans;
	
	while (scanf("%d %d", &a, &b) != EOF){
		if (a >= b){
			i = a;
		}
		else {
			i = b;
		}
		while (1){
			if (a % i == 0 && b % i == 0){
				printf("%d\n", i);
				break;
			}
			i--;
		}
	}
	
	return (0);
}

Measured memory_bytes: 596
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}

func readLines() -> [String] {
    return readLine()!.map { String($0) }
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}
// https://algo-logic.info/divisor/
/// 約数の配列を返す
func divisor(_ n:Int) -> [Int] {
    var ret = [Int]()
    var i = 1
    while i * i <= n {
        if n % i == 0 {
            ret.append(i)
            if i * i != n {
                ret.append(n / i)
            }
        }
        i += 1
    }
    return ret
}

func main() {
    let input = readInts()
    let (N, Y) = (input[0], input[1])
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    for i in 0...N {
        for j in 0...N - i {
            let k = N - i - j
            if k < 0 {
                break
            }
            if 10000 * i + 5000 * j + 1000 * k == Y && i + j + k == N {
                print(i, j, k)
                return
            }
        }
    }
    print("-1 -1 -1")
}
main()


Measured memory_bytes: 13608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int n;
	ll a[100000];
	ll ans=0;
	
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		ans+=(a[i]-1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

vector<vll> GF, GB;
set<ll> Component;
vb checked;

void dfs(ll s){
    if(checked[s]) return;
    checked[s] = true;
    Component.insert(s);
    for(auto u: GF[s]){
        if(!checked[u]) dfs(u);
    }
    return;
}

void solve(long long N, long long M, long long K, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C, std::vector<long long> D){
    REP(i, M){
        GF[A[i]].push_back(B[i]);
        GF[B[i]].push_back(A[i]);
    }
    REP(i, K){
        GB[C[i]].push_back(D[i]);
        GB[D[i]].push_back(C[i]);
    }
    vll ans(N, 0);
    REP(s, N){
        if(checked[s]) continue;
        Component.clear();
        dfs(s);
        if(Component.size() == 1) continue;
        for(auto x: Component){
            ans[x] += Component.size()-1-GF[x].size();
            for(auto y: GB[x]){
                if(Component.count(y)) ans[x]--;
            }
        }
    }
    REP(i, N){
        cout<<ans[i] <<" ";
    }
    cout<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long K;
    scanf("%lld",&K);
    GF.resize(N); GB.resize(N);
    checked.resize(N, false);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        A[i]--; B[i]--;
    }
    std::vector<long long> C(K);
    std::vector<long long> D(K);
    for(int i = 0 ; i < K ; i++){
        scanf("%lld",&C[i]);
        scanf("%lld",&D[i]);
        C[i]--; D[i]--;
    }
    solve(N, M, K, std::move(A), std::move(B), std::move(C), std::move(D));
    return 0;
}


Measured memory_bytes: 21492
def main():

    D, G = map(int, input().split())
    A = []
    for i in range(D):
        p, c = map(int, input().split())
        A.append([i, p, c])
    A = A[::-1]

    hs = [[0, 0, 0]]
    for i, p, c in A:
        temp = []
        for h, v, q in hs: temp.append([h|(1 << i), v+100*(i+1)*p+c, q+p])
        hs += temp

    # print(hs)

    ans = float('inf')
    for h, v, q in hs:
        if v >= G:
            ans = min(ans, q)
        else:
            for i, p, c in A:
                if (h >> i) % 2 == 0:
                    if v + 100*(i+1)*(p-1) < G:
                        v += 100*(i+1)*(p-1)
                        q += p-1
                    else:
                        if (G-v) % (100*(i+1)) == 0:
                            ans = min(ans, q + (G-v) // (100*(i+1)))
                        else:
                            ans = min(ans, q + 1 + (G-v) // (100*(i+1)))
                        break
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MN = 1e5+5;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    int N,M;
    cin >> N >> M;
    cout << N*(N-1)/2+M*(M-1)/2;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int N, H;
int a[100010], b[100010];


int solve(){
	int ans = 0;
	int A = *max_element(RNG(a, N));
	rep(i, 0, N){
		if(b[i] < A) break;
		H -= b[i];
		ans++;
		if(H <= 0) return ans;
	}
	return ans+CEIL(H/A);
}


signed main(){
	cin >> N >> H;
	rep(i, 0, N) cin >> a[i] >> b[i];

	sort(RNG(b, N), greater<int>());

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int cnt[26];

int main(){
  fill(cnt,cnt+26,1e9);
  
  cin>>n;
  for(int i=0;i<n;i++){
    string t;
    int u[26]={};
    cin>>t;
    for(int j=0;j<(int)t.size();j++){
      int ch=t[j]-'a';
      u[ch]++;
    }

    for(int j=0;j<26;j++)
      cnt[j]=min(cnt[j],u[j]);
  }

  for(int i=0;i<26;i++){
    for(int j=0;j<cnt[i];j++){
      cout<<(char)('a'+i);
    }
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define PI 3.14159265358979323846264
int main() {
	while (true) {
		long double p; cin >> p; if (p == 0)break;
		for (long double i = 0; i < 20000000; i += 1) {
			long double q1 = (PI - p) * i;
			long double q2 = (PI + p) * i;
			int r1 = q1, r2 = q2;
			if (r1 < r2) {
				cout << r2 << '/' << (int)i << endl; break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll ans,mx,sum,mn=1e8,cnt;

int main(){
	ll n;
	cin>>n;
	ll m=0;
	while(n>0){    
		m=n%10;    
		sum=sum+m;    
		n=n/10;
		ans++;    
	} 
//	cout<<sum<<endl;  
	cout<<max(sum,(9*(ans-1))+(m-1))<<endl;
	
}


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

int main(){
	ll N,A,B;
	cin >> N >> A >> B;
	
	ll count = N/(A+B);
	ll amari = N%(A+B);
	
	if(amari<=A){
		cout << A*count + amari << endl;
	}else{
		cout << A*count + A << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

typedef unsigned long long int ulli;

int N;
std::vector<ulli> a;
ulli ans = 0;

int main(){

  scanf("%d", &N);
  a.resize(N*3);
  for(auto& i : a){
    scanf("%lld", &i);
  }
  sort(a.begin(), a.end());
  for(int l = 1; l <= 2 * N; l++){
    if(l % 2 == 0){
      ans += a[N*3 - l];
    }
  }

  printf("%lld", ans);

  return 0;
}


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

using namespace std;
 
int main()
{
    int n;
    string str;
    while (cin >> n , n != -1) {
	str = "";
	if (!n) cout << '0' << endl;
	else {
	    while (n) {
		str += n % 4 + '0';
		n /= 4;
	    }
	    reverse(str.begin(), str.end());
	    cout << str << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3168
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0),A.append(0)
time = 0
now = 0
for i in range(N+2):
    time += abs(A[i]-now)
    now = A[i]
for i in range(1,N+1):
    if A[i-1] <= A[i] <= A[i+1]:
        print(time)
    else:
        print(time-((abs(A[i-1]-A[i])+abs(A[i]-A[i+1]))-abs(A[i-1]-A[i+1])))

Measured memory_bytes: 14176
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n;
int a[3010];

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    int sum = 0;
    for(int i=0;i<n;i++) sum += (a[i] - 1);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    string s; cin >> s;
    int K; cin >> K;

    for(int i=0; i<s.size(); ++i){
        int d = '{'-s[i];
        if(i != s.size()-1){
            if(s[i] == 'a') continue;

            if(d <= K){
                s[i] = 'a';
                K -= d;
            }
        }
        else {
            K %= 26;
            if(K < d){
                s[i] = (char)(s[i]+K);
                
            }
            else{
                s[i] = (char)('a' + K-d);
            }
        }
    }

    cout << s << endl;
}

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

int main() {
  
  int a, b = 1, N;
  cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v.at(i);
  }
  
  a = v.at(0);
  if (a != 2) {
    for (int i = 0; i < N; i++) {
    a = v.at(a - 1);
    b++;
    if (a == 2) break;
    }
  }
  
  if (b == N + 1) {
    cout << -1 << endl;
  } else {
    cout << b << endl;
  }
  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;

int pos[200100];
int L[200100];
int R[200100];

int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int N;
  cin >> N;
  rep(i,N){
    int x;
    cin >> x;
    x--;
    pos[x] = i;
  }
  //[left, right]
  set <int> memo = {-1,N};
  for (int i = 0; i < N; i++) {
    int x = pos[i];
    memo.insert(x);
    auto it= memo.find(x);
    auto it2 = it;
    L[i] = *(--it) + 1;
    R[i] = *(++it2) - 1;
  }
  ll ans = 0;
  rep(i,N){
    int l = L[i];
    int r = R[i];
    int p = pos[i];
    ans += (ll) (p-l+1) * (r-p+1) * (i + 1);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 12032
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

bool p[100001] = {};
vector<ll> g;

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

	ll size = 100001;
	rep(i, 0, size) p[i] = true;

	p[0] = false;
	p[1] = false;

	for (int i = 2; i*i < size; i++) {
		if (p[i]) {
			for (int j = 2; i*j < size; j++) {
				p[i*j] = false;
			}
		}
	}

	rep(i, 0, size) {
		if (p[i] && i % 10 == 1) {
			g.push_back(i);
		}
	}

	rep(i, 0, n
	) {
		cout << g[i];
		if (i != g.size() - 1) {
			cout << " ";
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  VI x(n), y(n); for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  lint res = 9e18;
  for (int xl = 0; xl < n; xl++) {
    for (int xr = 0; xr < n; xr++) {
      for (int yl = 0; yl < n; yl++) {
        for (int yr = 0; yr < n; yr++) {
          int t = 0;
          for (int i = 0; i < n; i++) {
            t += x[xl] <= x[i] and x[i] <= x[xr] and y[yl] <= y[i] and y[i] <= y[yr];
          }
          if (t >= k) {
            res = min(res, (lint) (x[xr] - x[xl]) * (y[yr] - y[yl]));
          }
        }
      }
    }
  }
  cout << res << '\n';
  return 0;
}

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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int N;
string S;
using H = unsigned long long;
namespace RollHash {
	constexpr int RANGE = 2123456;
	constexpr int MID = 512345;
	constexpr int num = 2;
	struct pH {
		H v[num];
		H& operator[](int i) {
			return v[i];
		}
	};
	constexpr H h[num] = { 1000000007llu,1000000009llu };
	pH RS[RANGE];
	map<pair<H, H>, LL> cnt;
	void init() {
		cnt.clear();
		for (int i : range(num)) {
			RS[0][i] = 1;
		}
		for (int i : range(1,RANGE)) {
			for (int j : range(num)) {
				RS[i][j] = RS[i - 1][j] * h[j];
			}
		}
	}
	inline pH add(pH has, int pos) {
		for (int i : range(num)) {
			has[i] += RS[MID + pos][i];
		}
		return has;
	}
	inline pH sub(pH has, int pos) {
		for (int i : range(num)) {
			has[i] -= RS[MID + pos][i];
		}
		return has;
	}
	inline pH sub(pH l, pH r) {
		for (int i : range(num)) {
			l[i] -= r[i];
		}
		return l;
	}

	constexpr int A = 512345;
	inline pH moveCenter(pH has, int nowCenter) {
		const int movement = A - nowCenter;
		for (int i : range(num)) {
			has[i] *= RS[movement][i];
		}
		return has;
	}
	inline pH shift(pH has, int sft) {
		const int movement = A +sft;
		for (int i : range(num)) {
			has[i] *= RS[movement][i];
		}
		return has;
	}
	inline void ins(pH has,int c) {
		cnt[{has[0], has[1]}] += c;
	}
	inline LL get(pH has) {
		return cnt[{has[0], has[1]}];
	}
}
int main() {
	using namespace RollHash;
	while (cin >> N >> S) {
		init();
		LL ret = 0;

		vector<pH> suf(N + 1);
		vector<int> sft(N + 1);
		sft[0] = 0;
		for (int i : range(N)) {
			sft[i + 1] = sft[i];
			if (S[i] == '>')sft[i + 1]++;
			if (S[i] == '<')sft[i + 1]--;
		}
		pH now{ 0,0 };
		int center = 0;
		suf[N] = shift(moveCenter(now, center), sft[N]);
		ins(suf[N], 1);
		for (int ri : range(N)) {
			const int i = N - 1 - ri;
			if (S[i] == '+')now = add(now, center);
			if (S[i] == '-')now = sub(now, center);
			if (S[i] == '>')center--;
			if (S[i] == '<')center++;
			suf[i]=shift(moveCenter(now, center),sft[i]);
			ins(suf[i], 1);
		}
		now = moveCenter(now, center);
		for (int i : range(N)) {
			ins(suf[i], -1);
			auto latte = suf[i];
			auto malta = shift(now, sft[i]);
			auto ei = sub(latte, malta);
			LL beet = get(ei);
			ret += beet;
		}

		cout << ret << endl;
	}
	return 0;
}


Measured memory_bytes: 69908
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    std::string s;
    std::cin >> s;
    std::deque<char> q;
    int ret = 0;
    for (int i = 0; i < s.size(); i++) {
        if (q.empty() || q.back() == s[i]) q.push_back(s[i]);
        else {
            q.pop_back();
            ret++;
        }
    }
    std::cout << 2 * ret << std::endl;

    return 0;
}


Measured memory_bytes: 512
import scala.io.StdIn.{readInt, readLine};
object Main {
    def main(args: Array[String]): Unit = {
        val n = readInt;
        val ig = new IntGraph(n);
        (1 to n).foreach { i =>
            readLine.split(" ").drop(2).map(_.toInt).foreach { j => ig.add(i, j)}
        }
        ig.dSearch.zipWithIndex.drop(1).foreach { e => println("%d %d %d".format(e._2, e._1(0), e._1(1)))}
    }
}
class IntGraph(n: Int) {
    val size: Int = n + 1;
    val matrix: Array[Array[Int]] = Array.ofDim[Int](size, size);
    def add(src: Int, dst: Int): Unit = matrix(src)(dst) = 1;
    
    def dSearch(): Array[Array[Int]] = {
        val status = Array.ofDim[Int](size, 2);
        def _dSearch(curr: Int, time: Int): Int = {
            status(curr)(0) = time;
            val newTime = 1 + (1 until size).foldLeft(time) { (t, i) =>
                if (matrix(curr)(i) == 1 && status(i)(0) == 0) _dSearch(i, t + 1) else t;
            }
            status(curr)(1) = newTime;
            newTime;
        }
        (1 until size).foldLeft(0) { (time, i)=>
            if (status(i)(0) == 0) {
                _dSearch(i, time + 1);
            } else {
                time;
            }
        }
        status;
    }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int mode = - 1;
    int ans = 1;
    for (int i = 1; i < n; i++){
        if (a[i] == a[i - 1]) continue;
        if (a[i] > a[i - 1]){
            if (mode == 0) continue;
            else if (mode == - 1) mode = 0;
            else {
                mode = - 1;
                ans++;
            }
        }
        else {
            if (mode == 1) continue;
            else if (mode == - 1) mode = 1;
            else {
                mode = - 1;
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <numeric>
#include <iostream>
using namespace std;

const int maxn = 2999;
double p[maxn];
double dp[maxn + 1] = {0};

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int heads = i + 1; heads >= 0; heads--) {
      dp[heads] = dp[heads] * (1 - p[i]);
      if (heads > 0)
        dp[heads] += dp[heads - 1] * p[i] ; 
    }
  }
  cout.precision(10);
  cout << accumulate(dp + n / 2 + 1, dp + n + 1, 0.0) << '\n';
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef struct{
  int y;
  int m;
  int d;
}Info;
typedef long long ll;

Info in[2];

int toY(int in){
  if(in%4) return 365;
  if(in%400 && in%100 == 0) return 365;
  return 366;
}

int toM(int in,int year){
  if(in == 2){
    if(toY(year) == 366) return 29;
    else return 28;
  }
  if(in == 4 || in == 6 || in == 9 || in == 11) return 30;
  return 31;
}

int toD(Info info){
  ll sum = 0;
  for(int i = 1; i < info.y; i++) sum += toY(i);
  for(int i = 1; i < info.m; i++) sum += toM(i,info.y);
  sum += info.d;
  return sum;
}

int main(){
  while(1){
    cin >> in[0].y >> in[0].m >> in[0].d;
    cin >> in[1].y >> in[1].m >> in[1].d;
    for(int i = 0; i < 2; i++){
      if(in[i].y < 0 || in[i].m < 0 || in[i].d < 0) return 0;
    }
    cout << toD(in[1])-toD(in[0]) << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

bool ok(const vecint& a, const int th, vecint& v) {
  ll n = a.size();
  v.assign(n*3, 0);
  int offset = n*1.5;
  ll cnt = 0;
  ll sum = 0;
  REP(i,n) {
    v[offset] += 1;
    if (a[i] >= th) {
      offset -= 1;
      sum -= v[offset];
    } else {
      sum += v[offset];
      offset += 1;
    }
    cnt += sum;
  }
  ll m = n * (n+1) / 2;
  ll mid = m/2 + 1;
  return cnt >= mid;
}

int main()
{
  int n;
  scanf("%d", &n);
  vecint a(n);
  REP(i,n) scanf("%d", &a[i]);
  vecint b = a;
  b.push_back(0);
  b.push_back(1000000007);
  sort(ALL(b));
  b.erase(unique(ALL(b)), end(b));
  int hi = b.size() - 1;
  int lo = 0;
  vecint v(n*4);
  while ((hi - lo) > 1) {
    int mid = (hi + lo) / 2;
    if (ok(a, b[mid], v)) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  printf("%d\n", b[lo]);
  return 0;
}


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

#define MAX_N (1<<19)+1

class BIT {
public:
    int limit;
    int last;
    map<int, int> m, mrev;
    vector<int> t;
    
    BIT(int l): limit(l), last(0), t(MAX_N, 0) {}

    void incubate(int rid) {
        if (t[MAX_N-1] == limit) {
            add(find(1), -1);
        }
        last ++;
        m[last] = rid;
        mrev[rid] = last;
        _add(last, 1);
    }

    void add(int rid, int x) {
        _add(mrev[rid], x);
    }

    void _add(int id, int x) {
        for (int i=id; i<MAX_N; i+=(i&-i)) {
            t[i] += x;
        }
    }

    int sum(int num) {
        int res = 0;
        for (int i=num; i>0; i-=(i&-i)) {
            res += t[i];
        }
        return res;
    }

    int find(int num) {
        if (sum(1) == num) {
            return m[1];
        }
        int l = 1, r = MAX_N;
        while (abs(r-l) > 1) {
            int mi = (l+r) / 2;
            if (sum(mi) < num) {
                l = mi;
            } else {
                r = mi;
            }
        }
        return m[l+1];
    }
};

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

    int q, lim;
    while (cin >> q >> lim, (q || lim)) {
        int query, x;
        BIT bit(lim);

        for (int i=0; i<q; ++i) {
            cin >> query >> x;
            if (query == 0) {
                bit.incubate(x);
            } else if (query == 1) {
                bit.add(bit.find(x), -1);
            } else if (query == 2) {
                cout << bit.find(x) << endl;
            } else if (query == 3) {
                bit.add(x, -1);
            }
        }
        cout << "end" << endl;
    }
}


Measured memory_bytes: 42564
import java.util.Scanner;

public class Main{
    
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    int K = sc.nextInt();
		String input = sc.next();
		
		//System.out.println(input);
		
		char c []  = input.toCharArray();
		sc.close();
		
		c[K-1] = Character.toLowerCase(c[K-1]);
		String output = new String(c);
		System.out.println(output);
		
	}

}


Measured memory_bytes: 23764
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORq(i, m, n) for(int i = (m); i < (n); i++)
#define FORr(i, n) for (int i = (n); i >= 0; i++)


int main() {
	int A, B, K;
	cin >> A >> B >> K;

	vector<int> dev;
	for (int i = 1; i <= 100; i++) {
		if (A % i == 0 && B % i == 0) {
			dev.emplace_back(i);
		}
	}
	sort(dev.rbegin(), dev.rend());
	if (K == 0) {
		cout << 0 << endl;
	}
	else {
		cout << dev[K - 1] << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pic pair<int,char>
#define pci pair<char,int>
#define pll pair<ll,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define vic vector<pic>
#define vci vector<pci>
#define vlc vector<plc>
#define vcl vector<pcl>
#define pb push_back
const ll MOD=1e9+7;
const ll MAXN=2e5+4;
const ll MAXM=1e5+3;
ll n,m,add1[MAXN];
ll ans[MAXN];
bool vis[MAXN];
vector<int>g[MAXN];
void dfs(int u,int sum)
{
    sum+=add1[u];vis[u]=1;
    ans[u]=sum;
    for(int i=0;i<g[u].size();i++)
    {
        if(vis[g[u][i]]==0)dfs(g[u][i],sum);
    }
    sum-=add1[u];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m;
    for(int i=1;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        add1[x]+=y;
    }
    dfs(1,0);
    for(int i=1;i<=n;i++)
    {
        cout<<ans[i]<<" ";
    }
    cout<<endl;
return 0;
}


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

int main() {
int s;
cin>>s;
if (1<=s/100&&s/100<=12)
{
  /* code */
  if (1<=s%100&&s%100<=12)
  {
    /* code */
    cout<<"AMBIGUOUS"<<endl;
  }
  else
  {
    cout<<"MMYY"<<endl;
  }
  
  
}
else
{
  if (1<=s%100&&s%100<=12){
    cout<<"YYMM"<<endl;
  }
  else
  {
    cout<<"NA"<<endl;
  }
  
}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int a,b,c;
	cin >> a>> b>> c;
    int ans=3;
    if(a==b&&b==c)ans=1;
    else if(a==b||b==c||c==a)ans=2;
      cout << ans << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $n, $m);
for($i = 0; $i < $n; $i++) {
    $n_arr[] = trim(fgets(STDIN));
}
for($j = 0; $j < $m; $j++) {
    $m_arr[] = trim(fgets(STDIN));
}
//var_dump($n_arr, $m_arr);
$ret = [];
foreach($n_arr as $n_key => $v) {
    foreach($m_arr as $m_key => $d) {
        $n_v = explode(' ', $v);
        $m_v = explode(' ', $d);
//var_dump($n_v, $m_v);
        $ret['n_'. ($n_key + 1)][$m_key + 1] = abs($n_v[0] - $m_v[0]) + abs($n_v[1] - $m_v[1]);
    }
}
//var_dump($ret);
for($i = 1; $i <= $n; $i++) {
    $min = min($ret['n_'. $i]);
    echo array_search($min, $ret['n_'. $i]). "\n";
}

Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

int ans[100010];

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,M; cin >> N >> M;
    vc<vi> G(N);
    rep(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].eb(b);
        G[b].eb(a);
    }
    rep(i,N) ans[i]=-1;
    ans[0]=0;
    queue<int> que;
    que.emplace(0);
    while(!que.empty()){
        int a=que.front(); que.pop();
        for(auto aa:G[a]){
            if(ans[aa]>=0) continue;
            else {
                ans[aa]=a;
                que.emplace(aa);
            }
        }
    }
    cout << "Yes" << endl;
    rng(i,1,N){
        cout << ans[i]+1 << endl;
    }
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define mod 1000000007

int main()
{

    ll n, m;
    cin >> n >> m;
    vector<ll> v(n+1,0);
    for(ll i = 0; i < m; i++)
    {

        ll a,b;
        cin >> a >> b;
        v[a]++;
        v[b]++;
    }
    for(ll i = 1; i <= n; i++)
    {

        cout << v[i] << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s,b,c;
	cin>>s>>b>>c;
	if(s[s.length()-1]==b[0] && b[b.length()-1]==c[0])
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		double N = sc.nextDouble();
		System.out.println(String.format("%.0f", Math.ceil(N / 2)));
		
		sc.close();
	}
	
}

Measured memory_bytes: 25172
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

int a, b;

bool can(int x){
	int A = x * 8 / 100;
	int B = x * 10 / 100;
	return A == a and B == b;
}

int main(){
	ri2(a,b);
	int ans = -1;
	for(int i = 1; i <= 1000; i++){
		if(can(i)){
			ans = i;
			break;
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

int main() {
    int N;
    int B[101];
    long ans = 0;
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        cin >> B[i];
        if (i > 0) ans += (long)min(B[i-1], B[i]);
    }
    ans += B[N-2] + B[0];
    cout << ans << endl;
}

Measured memory_bytes: 888
n=int(input())
li=[]
result=[]
for i in range(n):
  li.append(list(map(int,input().split())))
result.append(int(li[0][0]))
result.append(int(li[0][1]))
dic={}
for i in range(1,n):  
  if result[0]<=li[i][0] and result[1]<=li[i][1]:
    result=li[i]
    #result[1]=li[i][1]
  else:
    a=result[0]//li[i][0]
    b=result[1]//li[i][1]
    c=max(a,b)
    if result[0]>li[i][0]*c or result[1]>li[i][1]*c:
      c+=1
    result[0]=li[i][0]*c
    result[1]=li[i][1]*c
  #print(result[0],result[1])
print(result[0]+result[1])
        

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double;  using vld = vector<ld>; 

int main(void) {
	
	ll a,b,c,d; cin >>a>>b>>c>>d;
	if(a+b>c+d) cout <<"Left"<<endl;
	if((a+b)==(c+d)) cout <<"Balanced"<<endl;
	if(a+b<c+d) cout <<"Right"<<endl;

   return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <cstring>
#include <stdio.h>

using namespace std;

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

	int p = 0;
	string s[2] = { "","" };
	int q, f;
	char c;

	for (int i = 0; i < Q; i++) {
		cin >> q;
		if (q == 1) {
			p += q;
		}
		else {
			cin >> f >> c;
			s[(p + f + 1) % 2] += c;
		}
	}

	std::reverse(s[0].begin(), s[0].end());
	S = s[0] + S + s[1];
	if (p % 2 == 1) {
		std::reverse(S.begin(), S.end());
	}
	cout << S << endl;


	return 0;
}

Measured memory_bytes: 1348
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

double calc(int a, int b, int c, int d) {
  return sqrt((a - b) * (a - b) + (c - d) * (c - d));
}

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
  }
  vector<int> order(n);
  for (int i = 0; i < n; ++i) {
    order[i] = i;
  }
  double sum = 0.0;
  do {
    double res = 0.0;
    for (int i = 0; i + 1 < n; ++i) {
      res += calc(x[order[i]], x[order[i + 1]], y[order[i]], y[order[i + 1]]);
    }
    sum += res;
  } while (next_permutation(order.begin(), order.end()));
  int d = 1;
  for (int i = 1; i <= n; ++i) {
    d *= i;
  }
  printf("%.10f\n", sum / d);
  return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
double a[3000],f[3000][3000];
int main()
{
	int i,j,n;
	double ans=0.0;
	scanf("%d",&n);
	f[0][0]=1;
	f[0][1]=0;
	for(i=1;i<=n;i++)
	{
		scanf("%lf",&a[i]);
		f[i][0]=f[i-1][0]*(1-a[i]);
	}
	for(i=1;i<=n;i++)
		for(j=1;j<=i;j++)
			f[i][j]=f[i-1][j]*(1-a[i])+f[i-1][j-1]*a[i];
	for(i=(n+1)/2;i<=n;i++)
		ans+=f[n][i];
	printf("%.10lf",ans);
	return 0;
}

Measured memory_bytes: 68864
function Main(input) {
  input = input.split("\n");
  var S = input[0].split("");
  var ans=0;
  for(var i=0;i<Math.floor(S.length/2);i++){
    if(S[i]!=S[S.length-1-i]){
      ans++;
    }
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline-------------------------------------------
    s = input()
    if s[2]==s[3] and s[4] == s[5]:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 13696
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(auto &i:a) cin >> i;
  int ans = 0;
  for(int i=0;i<n-2;++i){
    vector<int> b(3);
    b[0] = a[i];
    b[1] = a[i+1];
    b[2] = a[i+2];
    sort(b.begin(),b.end());
    if(a[i+1]==b[1]) ++ans;
  }
  cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define irep(i, n) for(int i = n-1; i >= (int)0; i--)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int n,x;
    std::cin >> n>>x;
    std::vector<int>a(n) ;
    rep(i,n)std::cin >> a[i];
    sort(all(a));
    int cnt=0,ans=0;
    bool nu=1;
    rep(i,n){
        cnt+=a[i];
        if(cnt>x){
            ans=i;nu=0;break;
            
        }
    }
    if(nu){
        if(sum(all(a),0)==x)std::cout << n << std::endl;
        else std::cout << n-1 << std::endl;
    }
    else std::cout << ans << std::endl;
}

Measured memory_bytes: 256