akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int x, n, val;
bool dd[111];

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> x >> n;
    for (int i = 0; i < n; i++){
        cin >> val;
        dd[val] = true;
    }
    int res = 0;
    for (int i = 1; i <= 101; i++)
    if (!dd[i] && abs(i - x) < abs(res - x)){
        res = i;
    }
    cout << res;
    return 0;
}


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

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,k;
    cin >> n >> k;
    vector<int> v(n+1,0);

    for(int i=0;i<k;++i){
        int d;
        cin >> d;

        for(int j=0;j<d;++j){
            int x;
            cin >> x;
            v[x]++;
        }
    }

    int ans = 0;
    for(int i=1;i<=n;++i){
        if(v[i] == 0){
            ans++;
        }
    }

    cout << ans << "\n";
    return 0;
}

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

const int MAX=10000000;
int H, A[5000000];

void maxHeapfy(int i){
    int l,r,largest;
    l=2*i;
    r=2*i+1;

    if(l<=H && A[l]>A[i]) largest=l;
    else largest=i;
    if(r<=H && A[r]>A[largest]) largest=r;

    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapfy(largest);
    }
}

int main(){
    cin >> H;
    for(int i=1; i<=H; i++) cin >> A[i];

    for(int i=H/2; i>=1; i--) maxHeapfy(i);

    for(int i=1; i<=H; i++){
        printf(" %d",A[i]);
    } 
    printf("\n");
}


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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 1e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;



signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   int n, ans = 0;
   cin >> n;
   vi a(2 * n);
   for (int i = 0; i < n * 2; i++) {
      cin >> a[i];
   }
   sort(a.begin(), a.end());
   for (int i = 0; i < 2 * n; i+= 2) {
      ans+= a[i];
   }
   cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N,M,S;
int main() {
  cin >> N;
  if(N==1000000000){
        cout << "Yes" << endl;
  }else{
    M=N;
    for (int i=0;i<9;i++){
        S+=M%10;
        M/=10;
    }
    if(N%S==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
  }
}

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

ll const m = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	vector<ll> A(N), SumAj(N - 1);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	SumAj[N - 2] = A[N - 1];
	for (int i = N - 3; i >= 0; i--) {
		SumAj[i] = SumAj[i + 1] + A[i + 1];
		SumAj[i] %= m;
	}
	ll ans = 0;
	for (int i = 0; i < N - 1; i++) {
		ans = (ans + A[i] * SumAj[i]) % m;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 6372
import java.util.*;

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

        int result = 0;
        int baseHight =-1;

        for (int i =0; i<n; i++) {
           if (baseHight <= h[i]) {
               result++;
               baseHight = h[i];
           } 
        }
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 21332
#include<stdio.h>
int main(void)
{
   int A[100][100],b[100],c[100];
   int i,j,k,n,m;
   scanf("%d %d",&n,&m);
   for(i=0;i<n;i++){
     for(j=0;j<m;j++){
       scanf("%d",&A[i][j]);
     }
   }
   for(k=0;k<m;k++){
     scanf("%d",&b[k]);
   }
   for(i=0;i<n;i++){
     c[i]=0;
   }
   for(i=0;i<n;i++){
     for(j=0;j<m;j++){
       c[i]+=A[i][j]*b[j];
     }
   }
   for(k=0;k<n;k++){
     printf("%d\n",c[k]);
   }
   return 0;
}

Measured memory_bytes: 636
fn main() {
    let inputs: Vec<u32> = read_vec();
    let n = inputs[0];
    let d = inputs[1] as f64;
    let inputs: Vec<Vec<i64>> = read_vec2(n);

    let mut count = 0;
    for input in inputs.iter() {
        let x = input[0];
        let y = input[1];

        if ((x.pow(2) + y.pow(2)) as f64).sqrt() <= d {
            count += 1;
        }
    }

    println!("{}", count);
}

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

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

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}


Measured memory_bytes: 12808
#include<bits/stdc++.h>
using namespace std;
int a[100005],n,i,g,p[100005],k,j,ans[100005],tot;
int f[100005];
int gcd(int x,int y)
{
	return (y?gcd(y,x%y):x);
}
bool judge(int x)
{
	int i;
	for(i=0;i<=n&&i<x-1;++i)
	{
		long long s=0;
		for(j=i;j<=n;j+=x-1)
			s+=a[j];
		if(s%x!=0)
			return false;
	}
	return true;
}
int main()
{
	scanf("%d",&n);
	for(i=n;i>=0;--i)
		scanf("%d",&a[i]);
	for(i=1;i<=n;++i)
		g=gcd(abs(a[i]),g);
	for(j=2;j*j<=g;++j)
		if(g%j==0)
		{
			ans[++tot]=j;
			while(g%j==0)
				g/=j;
		}
	if(g!=1)
		ans[++tot]=g;
	if(a[0])
	{
		int j,s=abs(a[0]);
		for(j=2;j*j<=s;++j)
			if(s%j==0)
			{
				p[++k]=j;
				while(s%j==0)
					s/=j;
			}
		if(s!=1)
			p[++k]=s;
		for(i=1;i<=k;++i)
			if(judge(p[i]))
				ans[++tot]=p[i];
	}
	else
	{
		for(i=2;i<=10100;++i)
			if(f[i]==0)
				for(j=i*2;j<=10100;j+=i)
					f[j]=1;
		for(i=2;i<=10100;++i)
			if(f[i]==0)
				if(judge(i))
					ans[++tot]=i;
	}
	sort(ans+1,ans+1+tot);
	for(i=1;i<=tot;++i)
		if(ans[i]!=ans[i-1])
			printf("%d\n",ans[i]);
}


Measured memory_bytes: 384
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let h = read_vec::<i64>();

    let mut current_seq = 0;
    let mut max_seq = 0;
    for i in 1..n {
        if h[i] <= h[i - 1] {
            current_seq += 1;
        } else {
            current_seq = 0;
        }
        max_seq = max(max_seq, current_seq);
    }
    println!("{}", max_seq);
}

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

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


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back

typedef pair<int, int> ii;
typedef long long ll;
typedef pair<ll, ll> l4;

const int maxn = 1e6+1;
int n, m, perm[maxn], p[maxn];
int pa(int id)
{
  return id==p[id]?id:p[id]=pa(p[id]);
}
void merge(int x, int y)
{
  p[pa(x)] = pa(y);
}

int main()
{
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 1; i <= n; ++i)
    {
      scanf("%d", perm+i);
      p[i] = i;
    }
  for (int i = 1; i <= m; ++i)
    {
      int x, y;
      scanf("%d %d", &x, &y);
      merge(x, y);
    }
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    ans += pa(i) == pa(perm[i]);
  printf("%d\n", ans);
}




Measured memory_bytes: 4736
#abc176-c
import sys,math,collections,itertools
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
ans = 0
base=A[0]
for i in range(1,N):
    if A[i]>=base:
        base = A[i]
    else:
        ans += base-A[i]
print(ans)


Measured memory_bytes: 33772
#include <iostream>

using namespace std;

int red, k, green, blue;

int main()
{
    cin >> red >> green >> blue;
    cin >> k;

    if( (green * (1 << k) )> red)
    {
        while(k && green <= red)
            green <<= 1, k--;

        if( (blue * (1 << k) ) > green)
            cout << "Yes";
        else
            cout << "No";
    }

    else
        cout << "No";
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];
 
 
int main () {
    int R;
    scanf("%d",&R);
    printf("%f",2*R*PI);

}

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

using namespace std;

const int MOD = 1E9 + 7;
const int MAXN = 1E5;
int a[MAXN];
int fac[MAXN + 1];
int facInv[MAXN + 1];

int modInv(int x)
{
    int k = MOD - 2;
    int ans = 1;
    while (k)
    {
        if (k & 1)
        {
            ans = (int) (((long long) ans * x) % MOD);
        }
        x = (int) (((long long) x * x) % MOD);
        k >>= 1;
    }
    return ans;
}

int choose(int n, int k)
{
    int ans = (int) (((long long) fac[n] * facInv[n - k]) % MOD);
    ans = (int) (((long long) ans * facInv[k]) % MOD);
    return ans;
}

int main()
{
    fac[0] = facInv[0] = 1;
    for (int i = 1; i <= MAXN; i++)
    {
        fac[i] = (int) (((long long) fac[i - 1] * i) % MOD);
        facInv[i] = modInv(fac[i]);
    }
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    int ans = 0;
    for (int i = k - 1; i < n; i++)
    {
        int temp = (int) (((long long) a[i] * choose(i, k - 1)) % MOD);
        if (temp < 0)
            temp += MOD;
        ans += temp;
        if (ans >= MOD)
            ans -= MOD;
    }
    for (int i = n - k; i >= 0; i--)
    {
        int temp = (int) (((long long) a[i] * choose(n - 1 - i, k - 1)) % MOD);
        if (temp < 0)
            temp += MOD;
        ans += MOD - temp;
        if (ans >= MOD)
            ans -= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する

int N, M;
vector<vector<int> > G;

vector<int> color;

// ぼっちなら0
// 二部グラフなら1
// 二部グラフじゃないなら-1
// paint(v,1)で呼び出す
int paint(int v, int c) {
    if (G[v].size() == 0) return 0;
    if (color[v] != 0) {
        if (color[v] != c) return -1;
        return 1;
    }

    color[v] = c;
    int ret = 1;

    for (auto e : G[v]) {
        if (paint(e, -c) == -1) {
//            return -1;
            ret = -1;
        }
    }

    return ret;


}

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

    cin >> N >> M;
    G.resize(N);
    color.resize(N);


    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // x 二部じゃない y 二部 z ぼっち
    //(x + y) ^ 2 + y * y + 2 * z * N - 1が答え
    ll x = 0ll, y = 0ll, z = 0ll;

    for (int i = 0; i < N; ++i) {
        if (color[i] == 0) {
            int val = paint(i, 1);
            if (val == 0) z++;
            if (val == 1) y++;
            if (val == -1) x++;
        }
    }

//    ll ans = (x + y) * (x + y) + y * y + 2 * z * N - 1;
    ll ans = 1ll * N * N - 1ll * (N - z) * (N - z) + (x + y) * (x + y) + y * y;
    cout << ans << endl;

    return 0;
}


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

#define 	pie				3.1415926536
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(int i = a ; i < b ; i++)
#define 	mod1 			1000003
#define     mod2            998244353
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define 	F 				first
#define 	S 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define 	E 				end()
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define 	vi 				vector<int>
#define     pi              pair<int, int>
#define     vll             vector<long long int>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;

//g++ -std=c++14
//fixed<<setprecision(9);
//max_element(mp.begin(), mp.end(), compare)
//greater<int>()
// __gcd(a, b);

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }

bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }

void solve()
{
   ll n, sum = 0;cin>>n;
   rep(i, 1, n+1){
       if(i%3&&i%5){
           sum += i;
       }
   }
   cout<<sum<<nl;
}

int main()
{
    //boost;
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>


#define REP(i, n) for (long long i = 0; i < (n); i++) 
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1e+9;;

using namespace std;

int main()
{
    //    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());
    ll N,res;
    cin >> N;

    for(ll i = 1; i <= 9; i++)
    {
        if(N <= 111 * i)
        {
            res = 111 * i;
            break;
        }
    }

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h" // 提出時こちらで問題なし
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

int main() {
	// B - Magic 2
	int a, b, c, k;
	cin >> a >> b >> c;
	cin >> k;

	rep(i, k) {
		if (a >= b) {
			b *= 2;
		}
		else if (b >= c) {
			c *= 2;
			if (b < c) {
				cout << "Yes" << endl;
				return 0;
			}
		}
		else {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	//system("pause");
	return 0;
}

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

int main() {
    int numCoins;
    cin >> numCoins;
    vector<double> pHeads(numCoins);
    for(double& coin : pHeads) {
        cin >> coin;
    }

    int nTails = (numCoins - 1)/2;
    vector<double> memo(nTails+1, 0);

    memo[0] = pHeads[0];
    memo[1] = 1-pHeads[0];

	for(int coin = 1; coin < numCoins; coin++) {
        double pre = memo[0];
        memo[0] = pHeads[coin] * memo[0];
        for(int numTails = 1; numTails <= min(nTails, coin+1); numTails++) {
            double tmp = memo[numTails];
            memo[numTails] = pHeads[coin] * memo[numTails]
                            + (1-pHeads[coin]) * pre;
            pre = tmp;
        }
    }
    
    double result = 0;
    for(double num : memo) result += num;
    printf("%.15f", result);

    return 0;
}

Measured memory_bytes: 3244
#include<cstdio>
#include<cstring>
#include<algorithm>
int n,a,b,c,d;
long long ans,a1,b1;
template<class T>
inline void read(T&a){
	char c=getchar();
	for(a=0;c<'0'||c>'9';c=getchar());
	for(;c>='0'&&c<='9';c=getchar())a=a*10+c-'0';
}
int main(){
	read(n),read(a),read(b),read(c),read(d);
	for(int i=0;i<=n;i++){
		a1=(long long)i*c-(long long)(n-1-i)*d;
		b1=(long long)i*d-(long long)(n-1-i)*c;
		if(b-a>=a1&&b-a<=b1){puts("YES");return 0;}
	}
	puts("NO");return 0;
}

Measured memory_bytes: 128
from collections import Counter
n=int(input())
s=[]
for i in range(n):s.append(input())
m=int(input())
t=[]
for i in range(m):t.append(input())
cs=Counter(s).most_common()
ans=0
for i,j in cs:ans=max(ans,j-t.count(i))
print(ans)

Measured memory_bytes: 3316
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double N=sc.nextInt();
        double T=sc.nextInt();
        double A=sc.nextInt();
        int opt_h=1;
        double H=sc.nextInt();
        double t = T-H*0.006;
        double opt = Math.abs(A-t);

        for(int a=1;a<N;a++){
             H=sc.nextInt();
            t = T-H*0.006;
            double h = Math.abs(A-t);
            if(h<=opt){
                opt=h;
                opt_h=a+1;
            }
        }
        System.out.println(opt_h);
    }
}


Measured memory_bytes: 24532
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
using namespace std;
int N,M;
int k[10],s[10][10],p[10],lamp[10]={},num=0;
bool judans=true;

void saiki(int n,int jud){
	//printf("n=%d,jud=%d\n",n,jud);
	lamp[n]=jud;
	if(n>=N-1){
		//cout<<"n==N\n";
		for (int wri = 0; wri < N; wri++) {
			//cout<<lamp[wri]<<" ";
		}
		//cout<<"\n";

		for (int lm = 0; lm < M; lm++) {
			int tmp=0;
			for (int swi = 0; swi < k[lm]; swi++) {
				tmp+=lamp[s[lm][swi]-1];
			}
			//printf("tmp=%d\n",tmp);
			//printf("p[lm]=%d\n",p[lm]);

			if(tmp%2!=p[lm]){
				//cout<<"judfalse\n";
				judans=false;
				return;
			}
		}
		//cout<<"good\n";
		num++;
		return;
	}

	saiki(n+1,0);
	saiki(n+1,1);
}


int main(void) {

	cin>>N>>M;
	for (int i = 0; i < M; i++) {
		cin>>k[i];
		for (int l = 0; l < k[i]; l++) {
			cin>>s[i][l];
		}
	}
	for (int im = 0; im < M; im++) {
		cin>>p[im];
	}
	//cout<<"ok\n";

	saiki(0,0);
	//cout<<"\n\n\nfirst1\n";
	saiki(0,1);

	cout<<num<<"\n";


	return 0;
}


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

int N;
vector<string> elem;
string text;
bool dp[5050][1 << 12];
bool flg[5050][1 << 12];

bool check(int idx, int n){
	for(int i = 0; i < elem[n].size(); i++){
		if(idx + i >= text.size()) return false;
		if(text[idx + i] != elem[n][i]) return false;
	}
	return true;
}

bool dfs(int idx, int bit){
	if(bit == 0) return true;
	if(idx >= text.size()) return false;
	if(flg[idx][bit]) return dp[idx][bit];
	flg[idx][bit] = true;
	for(int i = 0; i < N; i++){
		if((1 << i) & bit){
			if(check(idx, i)){
				if(dfs(idx + elem[i].size(), bit & ~(1 << i))){
					return dp[idx][bit] = true;
				}
			}
		}
	}
	return dp[idx][bit] = false;
}

int main(){
	int m;
	while(cin >> N >> m, N){
		elem.resize(N);
		for(int i = 0; i < N; i++){
			cin >> elem[i];
		}
		text = "";
		for(int i = 0; i < m; i++){
			string str;
			cin >> str;
			text += str;
		}
		for(int i = 0; i <= text.size(); i++){
			for(int j = 0; j < (1 << N); j++){
				flg[i][j] = false;
			}
		}
		int ans = 0;
		for(int i = 0; i < text.size(); i++){
			ans += dfs(i, (1<<N) - 1);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 43036
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int MOD = 1e9+7;
const int N = 5*1e5;



int main(){
    AC
    int x, a, b;
    cin>>x>>a>>b;
    int ans = x;
    while(ans<=b){
        if(ans>=a && ans<=b){
            cout<<"OK"<<endl;
            return 0;
        }
        ans+=x;
    }
    cout<<"NG"<<endl;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<functional>

using namespace std;

int main()
{
	//freopen("input.txt", "r", stdin);
	
	int n, x, t;

	scanf("%d %d %d", &n, &x, &t);

	printf("%d\n", (n + x - 1) / x*t);

	return 0;
}

Measured memory_bytes: 1724
//by kcz 1552920354@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;

template <typename T> void chmin(T &x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef unsigned int u32;
typedef long long s64;
typedef unsigned long long u64;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define pb push_back
#define mp make_pair
#define gc (c=getchar())
char readc()
{
	char c;
	while(gc<'-');
	return c;
}
int read()
{
    char c;
    while(gc<'-');
    if(c=='-')
    {
        int x=gc-'0';
        while(gc>='0')x=x*10+c-'0';
        return -x;
    }
    int x=c-'0';
    while(gc>='0')x=x*10+c-'0';
    return x;
}
#undef gc

int main()
{
	int a,b,c,x,y,ans=2e9;
	cin>>a>>b>>c>>x>>y;
	rep(i,0,max(x,y))chmin(ans,2*c*i+max(0,x-i)*a+max(0,y-i)*b);
	cout<<ans;
}	



Measured memory_bytes: 256
N, x = map(int,input().split())
a = list(map(int,input().split()))
sum = 0
for i in range(N-1):
    if(a[i]>x):
        sum += a[i]-x
        a[i] = a[i]-(a[i]-x)
#    if(a[i+1]>x):
#        sum += a[i+1]-x
#        a[i+1] = a[i+1]-(a[i+1]-x)
    if(a[i]+a[i+1]>x):
        sum += a[i]+a[i+1]-x
        a[i+1] = a[i+1] - (a[i]+a[i+1]-x)
print(sum)

Measured memory_bytes: 14592
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)
 
const int MAXN = 1e5+4;
const int MOD = 1e9+7;
const int INF = 1e9+1;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int r; cin >> r;
    cout << r*r << endl;
    return 0;
}



Measured memory_bytes: 256
using System.Collections.Generic;
using static System.Math;
using System;

public class hello
{
    public static long t;
    public static int n;
    public static void Main()
    {
        t = long.Parse(Console.ReadLine().Trim());
        n = int.Parse(Console.ReadLine().Trim());
        var a = new long[n];
        var a2 = new long[2 * n];
        var a3 = new long[n + 1];
        var p = 0;
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var w0 = long.Parse(line[0]);
            var w1 = long.Parse(line[1]);
            a[i] = w0;
            a2[p++] = w0; a2[p++] = w1;
            a3[i + 1] = a3[i] + w1 - w0;
        }
        var ans = getAns(a, a2, a3);
        Console.WriteLine(ans);
    }
    static long getAns(long[] a, long[] a2, long[] a3)
    {
        var ans = 0L;
        for (int i = 0; i < n; i++)
        {
            var w = a[i] + t;
            var w1 = LowerBound(a2, w);
            var w2 = getSum(a2, a3, i, w, w1);
            ans = Max(ans, w2);
        }
        return ans;
    }
    static long getSum(long[] a2, long[] a3, int i, long w, long w1)
    {
        var a2L = 2 * n;
        if (w1 == a2L) return a3[n] - a3[i];
        else if (a2[w1] == w && w1 % 2 == 0) return a3[w1 / 2 + 1] - a3[i] + 1;
        else if (a2[w1] == w && w1 % 2 == 1) return a3[(w1 - 1) / 2 + 1] - a3[i];
        else if (a2[w1] != w && w1 % 2 == 1) return a3[(w1 - 1) / 2] - a3[i] + w - a2[w1 - 1];
        else return a3[w1 / 2] - a3[i];
    }
    static int LowerBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer)
    {
        int low = start;
        int high = end;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (comparer.Compare(arr[mid], value) < 0)
                low = mid + 1;
            else
                high = mid;
        }
        return low;
    }
    static int LowerBound<T>(T[] arr, T value) where T : IComparable
    {
        return LowerBound(arr, 0, arr.Length, value, Comparer<T>.Default);
    }
}



Measured memory_bytes: 26764
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
S, T = list(input().split())

for s, t in zip(S, T):
    print(s + t, sep='', end="")


Measured memory_bytes: 3064
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
b = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            for k in range(max(0, i - 1), min(i + 2, h)):
                for l in range(max(0, j - 1), min(j + 2, w)):
                    b[k][l] += 1
for i in range(h):
    t = ""
    for j in range(w):
        if a[i][j] == "#":
            t += "#"
        else:
            t += str(b[i][j])
    print(t)


Measured memory_bytes: 3064
class Pos:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def cal_distance(self, pos):
        return ((self.x - pos.x)**2 + (self.y - pos.y)**2)**0.5


N = int(input())
data = [input() for _ in range(N)]

pos_list = []
for d in data:
    x,y = map(int, d.split())
    pos = Pos(x, y)
    pos_list.append(pos)

result_list = []
for i in range(N):
    for j in range(N):
        cal = pos_list[i].cal_distance(pos_list[j])
        result_list.append(cal)

print(sum(result_list) / N)

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

int main() {
  int N;
  cin>>N;
  vector<int> a(N);
  int ans=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
    ans+=a[i];
  }
  if(ans%10!=0) cout<<ans<<endl;
  else{
    sort(a.begin(),a.end());
    int idx=0;
    while(ans%10==0&&idx<N){
      if(a[idx]%10!=0) ans-=a[idx];
      idx++;
    }
    if(ans%10!=0) cout<<ans<<endl;
    else cout<<0<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;cin >>n;
    map<int,int>m;
    for(int i=0;i<n;i++)
    {
        int a;cin>>a;
        m[a]+=1;
    }
    int sum=0;
    
    for(auto x: m){
        if (x.second%2!=0)
        {
            sum++;
        }
    }
    cout<<sum;
    
}


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

ll dp[100005][13];
const ll MOD = (ll)1e9 + 7;

void solve() {
    string s;
    cin >> s;

    dp[0][0] = 1;
    int n = s.size();
    s.push_back('0');
    reverse(s.begin(), s.end());
    ll mul = 1;
    for (int d = 1; d <= n; d++) {
        char c = s[d];
        if (c == '?') {
            rep(i, 10) {
                rep(j, 13) {
                    dp[d][(i * mul + j) % 13] += dp[d-1][j];
                    dp[d][(i * mul + j) % 13] %= MOD;
                }
            }
        } else {
            rep(j, 13) {
                dp[d][((c - '0') * mul + j) % 13] += dp[d-1][j];
                dp[d][((c - '0') * mul + j) % 13] %= MOD;
            }
        }
        mul *= 10;
        mul %= 13;
    }

    cout << dp[n][5] << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
typedef long long ll;
using namespace std;
const int inf=1e9;
int dp[(1<<16)];
int main(){
	int N,M,K;
	cin>>N>>M>>K;
	int D[16];
	REP(i,0,M) {
		cin>>D[i];
		D[i]--;
	}
	vector<int> root[110];
	int a;
	REP(i,0,N){
		REP(j,0,K){
			cin>>a;
			a--;
			root[i].push_back(a);
		}
	}
	REP(i,0,(1<<M)) dp[i]=inf;
	dp[(1<<M)-1]=0;
	queue<int> q;
	q.push((1<<M)-1);
	//bfs
	while(!q.empty()){
		int now=q.front();	q.pop();
		REP(j,0,K){
			int nstate=0;
			REP(i,0,M){
				if(now&(1<<i)) {
					//next room is dark or not
					int next=root[D[i]][j];
					int dr=-1;
					REP(k,0,M)	if(D[k]==next) dr=k;
					if(dr!=-1) nstate|=(1<<dr);
				}
			}
			if(dp[nstate]==inf) q.push(nstate);
			dp[nstate] = min(dp[nstate],dp[now]+1);
		}
	}
	p(dp[0]);
	return 0;
}

Measured memory_bytes: 3536
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int n;
	while (cin >> n && n) {
		VI a(n); rep(i, n)cin >> a[i];

		int now = 32;
		for (int i = 0; now != 0; i++) {

			if (i % 2 == 0) {
				now -= (now - 1) % 5;
			}
			else {
				now -= min(a[i / 2 % n], now);
			}

			Cout(now);
		}
	}
}


Measured memory_bytes: 2992
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<typename T>
struct BIT{
    vector<T> bit;
    int size;
    BIT(int n):size(n), bit(n+1, 0){}
    T sum(int i){ //[0, i)
        T s=0;
        while(i>0){
            s+=bit[i];
            i-=(i&(-i));
        }
        return s;
    }
    T sum(int l, int r){ //[l, r)
        return sum(r)-sum(l);
    }
    void add(int i, T x){
        i++;
        while(i<=size){
            bit[i]+=x;
            i+=(i&(-i));
        }
    }
};
int main()
{
	int n, q; cin>>n>>q;
	int c[500050];
	for(int i=0; i<n; i++){
		cin>>c[i];c[i]--;
	}
	int l[500050], r[500050];
	vector<int> vq[500050];
	for(int i=0; i<q; i++){
		cin>>l[i]>>r[i];
		l[i]--; r[i]--;
		vq[r[i]].push_back(i);
	}
	int ans[500050];
	int x[500050];
	fill(x, x+n, -1);
	BIT<int> bit(n);
	for(int i=0; i<n; i++){
		if(x[c[i]]>=0){
			bit.add(x[c[i]], -1);
		}
		x[c[i]]=i;
		bit.add(i, 1);
		for(auto j:vq[i]){
			ans[j]=bit.sum(n)-bit.sum(l[j]);
		}
	}
	for(int i=0; i<q; i++){
		printf("%d\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 36156
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>

using namespace std;

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


int main(){
    int a,b;
    cin >> a >>b;
    if(a + b == 15) cout << '+' << endl;
    else if(a*b == 15)  cout << '*' << endl;
    else cout << 'x' << endl;

    return 0;
}

Measured memory_bytes: 764
program main
  implicit none
  integer :: a, b, c
  logical :: flag = .false.
  read *, a, b, c

  if ((a <= c) .and. (b >= c)) flag = .true.
  if ((a >= c) .and. (b <= c)) flag = .true.

  if (flag) then
    print '(a)', 'Yes'
  else
    print '(a)', 'No'
  end if

end program

Measured memory_bytes: 640
rika=[]
for i in range(4):
    tensu=int(input())
    rika.append(tensu)
    
syakai=[]
for i in range(2):
    tensu=int(input())
    syakai.append(tensu)
    
rika.sort()
syakai.sort()

goukei=sum(rika[1:])+syakai[1]
print(goukei)



Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

//freopen("input.txt", "r", stdin);

int res[10000];
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   ll n,x,y;
   cin>>n>>x>>y;

   for(ll i=1;i<n;i++){
    for(ll j=i+1;j<=n;j++){
        ll t=min(abs(i-j),min(abs(x-i)+abs(y-j)+1,abs(y-i)+abs(x-j)+1));
        res[t]++;
    }
   }
   for(int i=1;i<n;i++) cout<<res[i]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (n+2-1)/2 << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 40;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

map<ll, int>  prime_factorization_map(ll x) {
  map<ll, int> res;
  for(ll i = 2; i*i <= x; ++i) {
    while(x % i == 0) {
      if(res.find(i) == res.end()) res[i] = 0;
      ++res[i];
      x /= i;
    }
  }
  if(x != 1) res[x] = 1;

  return res;
}

int main()
{
  ll n; cin >> n;
  auto primes = prime_factorization_map(n);
  ll ans = 0;
  vector<ll> num(1001);
  for(int i = 1; i <= 1000; ++i) num[i] = i*(i+1)/2;
  for(auto x : primes) {
    auto it = upper_bound(ALL(num), x.second);
    --it;
    ans += distance(num.begin(), it);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;
    s[K - 1] += 32;
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
    
#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
//#define int long long int
    
using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_mset = tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
    
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    
const ll mod = 998244353;
const int INF = 0x3f3f3f3f;
//const ll INFLL = (ll)1e17;
const int MAXN = 3123;
const double pi = 3.14159265359;
const double eps = 0.00000001;
 
int dp[MAXN][MAXN];
ii link[MAXN][MAXN];
bool flag[MAXN][MAXN];

int main() {
    $
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            int x = dp[i - 1][j - 1] + (s[i - 1] == t[j - 1]);
            int y = dp[i][j - 1];
            int z = dp[i - 1][j];
            if (x >= max(y, z)) {
                dp[i][j] = x;
                link[i][j] = {i - 1, j - 1};
                flag[i][j] = s[i - 1] == t[j - 1];
            } else if (y >= max(x, z)) {
                dp[i][j] = y;
                link[i][j] = {i, j - 1};
            } else {
                dp[i][j] = z;
                link[i][j] = {i - 1, j};
            }
        }
    }
    string ans;
    ii cur(n, m);
    while (cur != link[cur.F][cur.S]) {
        if (flag[cur.F][cur.S]) {
            ans += s[cur.F - 1];
        }
        cur = link[cur.F][cur.S];
    }
    reverse(all(ans));
    cout << ans << endl;
}

Measured memory_bytes: 123136
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 1;
  for (int i = 1; i < N; ++i) {
    if (S[i] != S[i - 1]) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
def solve():
    from sys import stdin
    f_i = stdin
    
    n = f_i.readline()
    A = list(map(int, f_i.readline().split()))
    
    q = int(f_i.readline())
    ans = []
    for i in range(q):
        com, b, e = map(int, f_i.readline().split())
        if com == 0:
            ans.append(str(min(A[b:e])))
        else:
            ans.append(str(max(A[b:e])))
    print('\n'.join(ans))

solve()


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

int main() {
  int16_t n;
  cin >> n;
  int16_t ary[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };

  for (int16_t i = 0; i < 8; i++) {
    if (n < ary[i]) {
      cout << ary[i - 1] << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int x = fs.nextInt();
        final int y = fs.nextInt();
        System.out.println(x + y / 2);
    }

    static final class Utils {
        public static void shuffleSort(int[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffleSort(long[] arr) {
            shuffle(arr);
            Arrays.sort(arr);
        }

        public static void shuffle(int[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void shuffle(long[] arr) {
            final Random r = new Random();

            for (int i = 0; i <= arr.length - 2; i++) {
                final int j = i + r.nextInt(arr.length - i);
                swap(arr, i, j);
            }
        }

        public static void swap(int[] arr, int i, int j) {
            final int t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        public static void swap(long[] arr, int i, int j) {
            final long t = arr[i];
            arr[i] = arr[j];
            arr[j] = t;
        }

        private Utils() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 32652
#include <stdio.h>
#include <math.h>

int main()
{
    int n;
    int i;
    double sum;
    double a;
    double s[1000];

    while(1) {
        scanf("%d", &n);
        if(n == 0) {
            break;
        }
        sum = 0;
        for(i = 0; i < n; i++) {
            scanf("%lf", &s[i]);
            sum += s[i];
        }
        a = 0;
        for(i = 0; i < n; i++) {
            a += pow(s[i] - (sum/n), 2);
        }
        printf("%f\n", sqrt(a/n));
    }
    return 0;
}


Measured memory_bytes: 2040
object Main extends App {
  val scan = new java.util.Scanner(System.in)
  val n = scan.next().toInt
  val ma = scan.next().toInt
  val mb = scan.next().toInt
  val ns = for ( _ <- (1 to n).toArray ) 
    yield (scan.next().toInt, scan.next().toInt, scan.next().toInt)
  val dp: Array[Array[Array[Option[Int]]]] = Array.fill(n+1, 400, 400)(None)
  dp(0)(0)(0) = Some(0)
  for ( i <- 1 to n ) {
    val (a, b, value) = ns(i-1)
    for ( j <- 0 until 400 ) {
      for ( k <- 0 until 400 ) {
        dp(i)(j)(k) = (dp(i-1)(j)(k), dp(i)(j)(k)) match {
          case (Some(n), Some(m)) => Some(math.min(n,m))
          case (Some(n), _)       => Some(n)
          case (_, Some(m))       => Some(m)
          case _                  => None
        }
        if (a+j<400 && b+k<400) {
          dp(i)(a+j)(b+k) = (dp(i-1)(j)(k), dp(i-1)(a+j)(b+k)) match {
            case (Some(n), Some(m)) => Some(math.min(n+value,m))
            case (Some(n), _)       => Some(n+value)
            case (_, Some(m))       => Some(m)
            case _                  => None
          }
        }
      }
    }
  }

  val costs = for (i <- 1 until 400; j <- 1 until 400;
    if ma*j == mb*i; if dp(n)(i)(j) != None) yield { dp(n)(i)(j).get }
          
  println(if (costs.nonEmpty) { costs.min } else { -1 })
}

Measured memory_bytes: 97008
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,popcnt")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<20, mod = 1e9 + 7, i2 = (mod+1)/2;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n, t, a = 0, b = 0, c = 0;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> t;
		if(t%4 == 0) a++;
		else if(t%2 == 0) b++;
		else c++;
	}
	int ok = (c <= (a + (b==0)));
	cout << (ok?"Yes\n":"No\n");
	return 0;
}


Measured memory_bytes: 256