akhauriyash/Code-Regression huggingface dataset:
n=int(input())
dp=[[0]*3 for i in range(n+1)]
for i in range(1,n+1):
    a,b,c=map(int,input().split())
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c
print(max(dp[-1]))


Measured memory_bytes: 22772
#include<iostream>
#include<string>

using namespace std;

int main(){
    int num=0;
    string str;
    string target = "Hoshino";
    string dest = "Hoshina";
    cin >> num;
    cin.ignore();
    
    for(int j=0;j<num;j++){
        getline(cin,str);
        string::size_type index = str.find(target);
        
        while(index != string::npos){
            str.replace(index,target.length(),dest);
            index = str.find(target,index+dest.length());
        }
        cout << str <<endl;
    }
    return 0;
}

Measured memory_bytes: 1212
fun main(args: Array<String>) {
    val n: Int = readLine()!!.toInt()
    val aList: List<Int> = readLine()!!.split(" ").map(String::toInt)
    for(i in 0..n-1) { 
        if(aList[i] % 2 == 0 && (aList[i] % 5 != 0 && aList[i] % 3 != 0)) {
            println("DENIED")
            return
        }
    }
    println("APPROVED")
}

Measured memory_bytes: 37756
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator bool () {
		int c = getchar();
		while(c != '0' and c != '1') c = getchar();
		return c == '1';
	}
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 4020;
bool a[maxn][maxn], b[maxn][maxn];
int sa[maxn][maxn], sb[maxn][maxn];

int main() {
	int n = read, m = read, q = read;

	for(int i = 2; i <= (n << 1); i += 2)
		for(int j = 2; j <= (m << 1); j += 2) {
			a[i][j] = read;
			b[i][j - 1] = (a[i][j] and a[i][j - 2]);
			b[i - 1][j] = (a[i][j] and a[i - 2][j]);
		}

	for(int i = 1; i <= (n << 1); i ++)
		for(int j = 1; j <= (m << 1); j ++)
			sa[i][j] = sa[i - 1][j] + sa[i][j - 1] + a[i][j] - sa[i - 1][j - 1];

	for(int i = 1; i <= (n << 1); i ++)
		for(int j = 1; j <= (m << 1); j ++)
			sb[i][j] = sb[i - 1][j] + sb[i][j - 1] + b[i][j] - sb[i - 1][j - 1];

	while(q --) {
		int x1 = read, y1 = read, x2 = read, y2 = read;
		x1 <<= 1;
		y1 <<= 1;
		x2 <<= 1;
		y2 <<= 1;
		printf("%d\n", sa[x2][y2] - sa[x2][y1 - 1] - sa[x1 - 1][y2] + sa[x1 - 1][y1 - 1] -
				(sb[x2][y2] - sb[x2][y1 - 1] - sb[x1 - 1][y2] + sb[x1 - 1][y1 - 1]));
	}
}


Measured memory_bytes: 159488
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
#define DBG(str) cerr << (str) << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail)
{
  cerr << head << ", ";
  //DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  VEC<int> x(n);
  REP(i, 0, n)
  {
    cin >> x[i];
  }
  //DUMP(x);
  LL ans = 0;
  REP(i, 0, n - 1)
  {
    LL dx = x[i + 1] - x[i];
    if (a * dx < b)
      ans += a * dx;
    else
      ans += b;
    //DUMP(ans, dx);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
// -*- coding:utf-8-unix -*-

use std::cmp::*;
use std::collections::*;
use std::fs::File;
use std::io::prelude::*;
use std::io::*;
use std::vec;

const INF: i64 = 1223372036854775807;
const MEM_SIZE: usize = 202020;
const MOD: i64 = 1000000007;
use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;
#[allow(dead_code)]
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()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn readii() -> (i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}
#[allow(dead_code)]
fn readuu() -> (usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(dead_code)]
fn readuuu() -> (usize, usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[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 solve() {
    let n: usize = read();
    let mut vec: Vec<usize> = vec![0; n];
    for i in 0..n {
        let x: usize = read();
        vec[i] = x;
    }
    let mut res = 0 as usize;
    if (vec[0] != 0) {
        println!("{:?}", -1);
        return;
    }

    for i in 0..n - 1 {
        if (vec[i + 1] > vec[i] + 1) {
            println!("{:?}", -1);
            return;
        } else if vec[i + 1] == vec[i] + 1 {
            res += 1;
        } else {
            res += vec[i + 1];
        }
    }
    println!("{:?}", res);

    return;
}
fn main() {
    solve()
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	constexpr Int MOD = 998244353;
	int N, K;
	cin >> N >> K;
	vector<int> L(K), R(K);
	for (int i = 0; i < K; ++i) {
		cin >> L[i] >> R[i];
	}

	vector<Int> d(N + 10, 0);
	vector<Int> a(N + 10, 0);
	a[1] = 1;
	for (int i = 1; i <= N; ++i) {
		(d[i] += d[i - 1]) %= MOD;
		(a[i] += d[i]) % MOD;
		for (int k = 0; k < K; ++k) {
			if (i + L[k] > N) { continue; }
			int r = min(N, i + R[k]) + 1;
			(d[i + L[k]] += a[i]) %= MOD;
			(d[r] += MOD - a[i]) %= MOD;
		}
	}
	cout << a[N] % MOD << "\n";

	return 0;
}


Measured memory_bytes: 6420
# coding: utf-8
# 日本語を入力できるようにするために上記一文が必要


x, y = map(int, input().split() )
num_list = list(map(int, input().split() ) )

num_list.sort()

ans = 0
for i in range(y):
        ans += num_list[i]

print(ans)

Measured memory_bytes: 9236
while True:
    a, op, b = raw_input().split()
    if op == "?":
        break
    else:
        if op == '+':
            print int(a) + int(b)
        elif op == '-':
            print int(a) - int(b)
        elif op == '*':
            print int(a) * int(b)
        elif op == '/':
            print int(a) / int(b)
        else:
            print "error"

Measured memory_bytes: 6444
#include <iostream>
#include <string>
#include <algorithm>

int calc(std::string s, int offset)
{
    int ans = 0;
    for (int i = 0; i < s.length(); ++i)
    {
        int mod = (offset + i) % 2;
        if (s[i] == '0' && mod != 0)
        {
            ans++;
        }
        else if (s[i] == '1' && mod != 1)
        {
            ans++;
        }
    }

    return ans;
}

int main()
{
    std::string S;
    std::cin >> S;

    std::cout << std::min(calc(S, 0), calc(S, 1)) << std::endl;

    return 0;
}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,ans=0; cin>>n;
    string s; cin>>s;
    rep(i,n-2){
        if(s[i]!='A') continue;
        if(s[i+1]!='B') continue;
        if(s[i+2]!='C') continue;
        ans++;
    }
    cout<<ans<<endl;
}


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

int main() {
    string s, t;
    cin >> s >> t;

    string ss = s + s;
    for (int i = 0, n = t.size(); i < n; i++)
        if (ss.substr(i, n) == t) {
            cout << "Yes" << endl;
            return 0;
        }

    cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

struct data{
	double t;
	int v;
	data(int vv=0,double tt=0){
		v=vv;
		t=tt;
	}
	bool operator<(const data &d1)const{
		return t<d1.t;
	}
};

int n;
double pw;
double vw[100001],pf[100001],vf[100001],th[100001];
data query[100001];

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		scanf("%lf",&pw);
		double sum=0.0;
		double dif=0.0;
		double res=0.0;
		int size=0;
		for(int i=0;i<n;i++){
			scanf("%lf %lf %lf %lf",&vw[i],&pf[i],&vf[i],&th[i]);
			if(th[i]>0){
				res+=th[i]/vf[i]*pf[i];
				sum+=th[i]/vf[i]*pf[i];
				if(vw[i]>0){
					query[size++]=data(i,th[i]/vw[i]);
				}
				dif+=vw[i]/vf[i]*pf[i];
			}else{
				if(vw[i]<0){
					query[size++]=data(i,-th[i]/-vw[i]);
				}
			}
		}
		sort(query,query+size);
		double prev=0.0;
		for(int i=0;i<size;i++){
			sum-=dif*(query[i].t-prev);
			res=min(res,max(sum,0.0)+query[i].t*pw);
			if(vw[query[i].v]<0)dif+=vw[query[i].v]/vf[query[i].v]*pf[query[i].v];
			if(vw[query[i].v]>0)dif-=vw[query[i].v]/vf[query[i].v]*pf[query[i].v];
			prev=query[i].t;
		}
		printf("%.10f\n",res);
	}
	return 0;
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

s64 N, M, d;

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

    cin >> N >> M >> d;

    if (d != 0)
    {
        cout << setprecision(10) << (double)2 * ((double)N - d) * ((double)M - 1) / ((double)N * N) << "\n";
    }
    else
    {
        cout << setprecision(10) << ((double)M - 1) / (double)N << "\n";
    }

    return 0;
}



Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;
#define cni cin

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
//typedef unsigned int uint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,ans;

main(){
	cin>>n;
	int a[n],b[n];
	//pair<int,int> b[n];
	rep(i,n){
	    cin>>a[i];
	    a[i]-=i+1;
	    //b[i]=mp(a[i],i);
	    b[i]=a[i];
	}
	sort(b,b+n);
	//int t=b[n/2].fi-(b[n/2].se+1);
	int t=b[n/2];
	//cout<<t<<' '<<a[n/2]<<' '<<(n+1)/2<<endl;
	//cout<<t<<endl;
	rep(i,n){
	    //cout<<abs(a[i]-t)<<endl;
	    ans+=abs(a[i]-t);
	}
	dans;
}



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

int main() {
	long long a, b;
	cin >> a >> b;
	if (a < 0) {
		if (b < 0) {
			if ((b - a + 1) % 2 == 0) {
				cout << "Positive" << endl;
			}
			else {
				cout << "Negative" << endl;
			}
		}
		else {
			cout << "Zero" << endl;
		}
	}
	else if (a == 0) {
		cout << "Zero" << endl;
	}
	else {
		cout << "Positive" << endl;
	}
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M,X;
int C[12],A[12][12];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>X;
	FOR(i,N) {
		cin>>C[i];
		FOR(x,M) cin>>A[i][x];
	}
	
	int mi=1<<30;
	int mask;
	FOR(mask,1<<N) {
		int sum=0;
		FOR(i,N) if(mask&(1<<i)) sum+=C[i];
		if(sum>=mi) continue;
		FOR(i,M) {
			int ok=0;
			FOR(j,N) if(mask&(1<<j)) ok+=A[j][i];
			if(ok<X) break;
		}
		if(i==M) mi=sum;
	}
	
	if(mi==1<<30) mi=-1;
	cout<<mi<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3660
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Foldable
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> VU.Vector Int -> Int
solve n hs = VU.sum hs' - if even countOfNegative then 0 else 2 * minhs
 where
  hs'             = VU.map abs hs
  countOfNegative = VU.length $ VU.filter (< 0) hs
  minhs           = VU.minimum hs'

main = do
  let readInt = fmap (second B.tail) . B.readInt

  n  <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  hs <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n hs


Measured memory_bytes: 6524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define INF 1000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
// #define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  REP(i, n) { cin >> h.at(i); }
  int dp[n];
  REP(i, n) { dp[i] = INF; }
  dp[0] = 0;
  REP(i, n) {
    if (i + 1 < n)
      dp[i + 1] = min(dp[i] + abs(h.at(i + 1) - h.at(i)), dp[i + 1]);
    if (i + 2 < n)
      dp[i + 2] = min(dp[i] + abs(h.at(i + 2) - h.at(i)), dp[i + 2]);
  }
  cout << dp[n-1] << "\n";
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    char a;
    cin>>a;
    if(a=='a'){
        cout<<'b';
    }
    if(a=='b'){
        cout<<'c';
    }
    if(a=='c'){
        cout<<'d';
    }
    if(a=='d'){
        cout<<'e';
    }
    if(a=='e'){
        cout<<'f';
    }
    if(a=='f'){
        cout<<'g';
    }
    if(a=='g'){
        cout<<'h';
    }
    if(a=='h'){
        cout<<'i';
    }
    if(a=='i'){
        cout<<'j';
    }
    if(a=='j'){
        cout<<'k';
    }
    if(a=='k'){
        cout<<'l';
    }
    if(a=='l'){
        cout<<'m';
    }
    if(a=='m'){
        cout<<'n';
    }
    if(a=='n'){
        cout<<'o';
    }
    if(a=='o'){
        cout<<'p';
    }
    if(a=='p'){
        cout<<'q';
    }
    if(a=='q'){
        cout<<'r';
    }
    if(a=='r'){
        cout<<'s';
    }
    if(a=='s'){
        cout<<'t';
    }
    if(a=='t'){
        cout<<'u';
    }
    if(a=='u'){
        cout<<'v';
    }
    if(a=='v'){
        cout<<'w';
    }
    if(a=='w'){
        cout<<'x';
    }
    if(a=='x'){
        cout<<'y';
    }
    if(a=='y'){
        cout<<'z';
    }
    
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] temp = br.readLine().split(" ");
		Integer n = Integer.parseInt(temp[0]);
		Integer a = Integer.parseInt(temp[1]);
		Integer b = Integer.parseInt(temp[2]);
		int p,sum,res = 0;
		for(int i=1;i<=n; i++) {
			p = i;
			sum = 0;
			while(p > 0) {
				sum += p % 10;
				p /= 10;
			}
			if(a <= sum && b >= sum) res += i;
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 22356
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
    int t;
    cin>>t;

    int arr[t];

long long int sum = 0;
    for(int i=0;i<t;i++)
  {  cin>>arr[i];}
  //sum+=arr[i];}

    sort(arr,arr+t);
//sum = sum - arr[0];

//cout<<sum<<endl;
sum = arr[t-1];
int turn = 1;
for(int i=t-2;i>=0;i--)
{
    if(turn==t-1)
    {
        break;
    }
    else
    {
       sum = sum + arr[i];
       turn++;
       if(turn==t-1)
       break;
       else
       {
           sum = sum+arr[i];
           turn++;
       }
       
    }
    
}

cout<<sum<<endl;
    
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<int> l(M);
    vector<int> r(M);
    for (int i = 0; i < M; i++) {
        cin >> l.at(i) >> r.at(i);
    }
    sort(l.begin(), l.end());
    sort(r.begin(), r.end());
    int cnt = 0;
    for (int i = l.at(M-1); i <= r.at(0); i++) {
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3984
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
const long long mx =1e15;

int main()

{
    ios::sync_with_stdio(0);
    cin.tie(0);
    double t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n;//>>s2;
    l(i,0,n)
    {
      cin>>a;
      s.in(a);
    }
    if(n==s.size())
    {
        cout<<"YES";
    }
    else{

    cout<<"NO"<<endl;

}}


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

long long k;
long long  n,my,ans[50];
int main(){
    cin>>k;
	n=50;
	my=k-(k/50*50);
	for(int i=0;i<n;i++){
		ans[i]=n+(k/n)-my-1;
	}
	for(int i=0;i<my;i++){
		ans[i]++;
		ans[i]+=my;
	}
	cout<<50<<endl;
	for(int i=0;i<49;i++){
		cout<<ans[i]<<" ";
	}
	cout<<ans[49]<<endl;
	

    return 0;
} 

Measured memory_bytes: 256
N, K = map(int, input().split())
A = []

for i in range(K):
    d = int(input())
    A.append(list(map(int, input().split())))

s = set()
for i in range(K):
    for a in A[i]:
        s.add(a)

# print(s)
print(N - len(s))


Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define f(a) for (ll i = 0; i < a; i++)
#define fio                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);


using namespace std;



int main()
{
    fio;
    ll n,w,i,j,temp;
    cin>>n>>w;
    ll arr[n][2];
    f(n){cin>>arr[i][0]>>arr[i][1];}
    for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(arr[i][0]>arr[j][0])
			{
				swap(arr[i][0],arr[j][0]);
				swap(arr[i][1],arr[j][1]);
			}
			if(arr[i][0]==arr[j][0])
            {
                if(arr[i][1]<arr[j][1])
                {
                    swap(arr[i][0],arr[j][0]);
                    swap(arr[i][1],arr[j][1]);
                }

            }

		}
	}
    //f(n){cout<<arr[i][0]<<" "<<arr[i][1]<<endl;}

    ll ab[n+1][w+1];
    ll sum[n][2];
    sum[0][0]=arr[0][0];
    sum[0][1]=arr[0][1];
    for(i=1;i<n;i++)
    {
        sum[i][0]=arr[i][0]+sum[i-1][0];
        sum[i][1]=arr[i][1]+sum[i-1][1];
    }
    for(i=0;i<n+1;i++)
    {
        for(j=0;j<w+1;j++)
        {ab[i][j]=0;}}


    for(i=1;i<n+1;i++)
    {
        for(j=1;j<w+1;j++)
        {   if(j<arr[i-1][0]){ab[i][j]=ab[i-1][j];}
            else if(j==arr[i-1][0]){ab[i][j]=max(arr[i-1][1],ab[i-1][j]);}
            else {ab[i][j]=max(ab[i-1][j],ab[i-1][j-arr[i-1][0]]+arr[i-1][1]);}


        }
    }
  /*  f(w+1){cout<<i<<" ";}
    cout<<endl;
    for(i=1;i<n+1;i++)
    {   cout<<arr[i-1][0]<<" ";
        for(j=1;j<w+1;j++)
        { cout<<ab[i][j]<<" ";}
        cout<<endl;
    }*/
    //  f(n){cout<<sum[i][0]<<" "<<sum[i][1]<<endl;}
     cout<<ab[n][w];
    return 0;
}



Measured memory_bytes: 82444
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef long long ll;

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

    if(n%10==7)
    {
        printf("Yes\n");
    }
    else
    {
        n=n/10;
        if(n%10==7)
        {
            printf("Yes\n");
        }
        else
        {
            n=n/10;
            if(n==7)
            {
                printf("Yes\n");
            }
            else
            {
                printf("No\n");
            }
        }
        
    }
}

Measured memory_bytes: 1620
# dpE - Knapsack 2
import sys
input = sys.stdin.readline

def heavy_knapsack(W: int, weight: "Array[int]", value: "Array[int]") -> int:
    lim = sum(value)
    dp = [0] + [float("inf")] * lim  # dp[i] := minimum weight of value i
    for w, v in zip(weight, value):
        for cur_v in range(lim, v - 1, -1):
            dp[cur_v] = min(dp[cur_v], dp[cur_v - v] + w)
    ret = max(v for v, w in enumerate(dp) if w <= W)
    return ret


def main():
    N, W = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N))
    w, v = zip(*A)
    ans = heavy_knapsack(W, w, v)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 70604
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  int odd = 1;
  for (int i = 0; i < N; i++) if (!(a[i] & 1)) {
    odd *= 2;
  }

  // 解答
  cout << pow(3, N) - odd << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize("03")
#define ll long long
#define ld long double
#define fi first
#define se second

using namespace std;

ll a, b, k;

int main() {
//	ifstream cin("tst.in");
//	ofstream out("tst.out");
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cin >> a >> b >> k;
	bool f = 1;
	for (int i = 1; i <= k; i++) {
		if (f == 1) {
			if (a & 1LL)
				a--;
			b += a / 2LL;
			a /= 2LL;
		} else {
			if (b & 1LL)
				b--;
			a += b / 2LL;
			b /= 2LL;
		}
		f = !f;
	}
	cout << a << ' ' << b;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 int main(void)
 {
 int i, j, H, W;
 while (1) 
{
 scanf("%d %d", &H, &W);
 if (H == 0 && W == 0)
 {
 break;
 }
 for (i = 0; i < H;
 i++)
 {
 for (j = 0;
 j < W;
 j++)
 {
 if (i % 2 == 0 && j % 2 == 1)
 {
 printf(".");
 }
 else if (i % 2 == 1 && j % 2 == 0)
 {
 printf(".");
 }
 else
 {
 printf("#");
 }
 }
 printf("\n");
 }
 printf("\n");
 }
 return(0);
 } 


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	while (cin >> n) {
		vector<int> a(n);
		for (int &x : a) {
			cin >> x;
		}
		int ma = a[0];
		long long ans = 0;
		for (int i = 1; i < n; i++) {
			ans += max(0, ma - a[i]);
			ma = max(ma, a[i]);
		}
		cout << ans << '\n';
	}
	return 0;
}


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

int a[200001], n, q, t1, t2;
vector<int> g[200001];

void dfs(int p)
{
    for (int i : g[p])
        a[i] += a[p], dfs(i);
}

int main()
{
    cin >> n >> q;
    for (int i = 0; i < n - 1; ++i)
        cin >> t1 >> t2, g[t1].push_back(t2);
    for (int i = 0; i < q; ++i)
        cin >> t1 >> t2, a[t1] += t2;
    dfs(1);
    for (int i = 1; i <= n; ++i)
        cout << a[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 20352
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

int main()
{
    ll N;
    cin >> N;
    N -= 1;
    cout << N*(N+1)/2 << endl;
}

Measured memory_bytes: 256
(* 配列版素集合データ構造 *)
module UnionFind : sig
  type t

  module Class : sig
    type t
    val compare : t -> t -> int
  end

  (* n要素の素集合データ構造を作る *)
  val make : int -> t
  (* 要素がどの集合に属するか調べる *)
  (* 要素は0からn-1の整数である必要がある *)
  val find : t -> int -> Class.t
  (* 与えられた集合同士を合併する *)
  (* 破壊的操作であるため注意 *)
  val unite : t -> Class.t -> Class.t -> unit
  (* 与えられた集合に属する要素の数を求める *)
  val cardinal : t -> Class.t -> int
end = struct
  type t = int array

  module Class = struct
    type t = int
    let compare = compare
  end

  let make n = Array.make n (-1)

  let rec find uf x =
    if uf.(x) < 0 then x
    else begin
      let y = find uf uf.(x) in
      uf.(x) <- y; y
    end

  let unite uf x y =
    if x <> y then begin
      let x, y = if uf.(x) <= uf.(y) then x, y else y, x in
      uf.(x) <- uf.(x) + uf.(y);
      uf.(y) <- x
    end

  let cardinal uf x = ~- (uf.(x))
end

module WeightedGraph
  (Weight : sig
    type t
    val compare : t -> t -> int
  end) :
sig
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  (*
   * HashtblやMapを用いているとプリム法と大差ない計算時間になってしまうため，
   * より汎用的な実装が欲しければそちらを当たること
   *)
  val kruskal :
    (* 頂点の数n *)
    int ->
    (* 辺のリスト *)
    (* 頂点は0からn-1までの整数でなくてはならない
       ソートにList.sortを使っているせいでデータ構造が固定されており，あまり良くない… *)
    (int * int * Weight.t) list ->
    (* 最小全域木に含まれる辺のリスト
       畳み込む関数と初期値まで与えられて初めて計算を開始するので，
       最小全域木に対して色々な操作をしたい場合は，
       一度リストにして覚えておくとよい．
       最小全域木の重さの和だけ欲しいとか一回しか使わない場合は，
       直接畳み込む関数と初期値を与えるとdeforestationになっていい感じ． *)
    (int * int * Weight.t) church_list
end =
struct
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  let kruskal n es =
    { fold = fun f init ->
      let uf = UnionFind.make n in
      List.fold_left (fun acc (u, v, w) ->
        let c = UnionFind.find uf u in
        let d = UnionFind.find uf v in
        if UnionFind.Class.compare c d = 0
        then acc
        else (UnionFind.unite uf c d; f (u, v, w) acc)) init @@
      List.sort (fun (_, _, w) (_, _, w') -> Weight.compare w w') es }
end
 
module Int = struct
  type t = int
  let compare = compare
end
 
module G = WeightedGraph (Int)
 
let () =
  let n = Scanf.scanf "%d\n" @@ fun n -> n in
  let xys = Array.to_list @@ Array.init n @@ fun i ->
    Scanf.scanf "%d %d\n" @@ fun x y -> x, y, i in
  let xedges =
    List.sort (fun (x, _, _) (x', _, _) -> compare x x') xys
    |> (fun ((x, y, i) :: xys) ->
        List.fold_left (fun (acc, x, y, i) (x', y', j) ->
          ((i, j, x' - x) :: acc, x', y', j)) ([], x, y, i) xys)
    |> (fun (acc, _, _, _) -> acc) in
  let yedges =
    List.sort (fun (_, y, _) (_, y', _) -> compare y y') xys
    |> (fun ((x, y, i) :: xys) ->
        List.fold_left (fun (acc, x, y, i) (x', y', j) ->
          ((i, j, y' - y) :: acc, x', y', j)) ([], x, y, i) xys)
    |> (fun (acc, _, _, _) -> acc) in
  Printf.printf "%d\n" @@
  (G.kruskal n (List.rev_append xedges yedges)).G.fold (fun (_, _, d) -> ( + ) d) 0


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  
  ll n, k; cin >> n >> k;
  ll mx = 0, g = 0;

  rep(i, n) {
    ll a; cin >> a;
    chmax(mx, a);
    g = __gcd(g, a);
  }

  if (mx < k) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }

  if (k % g == 0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    for(ll i=0;i<n;++i){
        if(a[i] == 0){
            cout<<0<<endl;
            return 0;
        }
    }

    ll ans = a[0];
    for(ll i=1;i<n;++i){
        if(ans > 1000000000000000000 / a[i]){
            ans = -1;
            break;
        }else{
            ans = ans * a[i];
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4416
#include <stdio.h>

int main(void){
	int a,b,c,t,n;
	
	scanf("%d",&n);
	
	for(;n--;){
		scanf("%d %d %d",&a,&b,&c);
	
		if(a>b) t=a, a=b, b=t;
		if(b>c) t=c, c=b, b=t;
	
		if(c*c!=b*b+a*a) printf("NO\n");
		else printf("YES\n");
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string ans;
    if (N >= 1000){
        ans = "ABD";
    }else{
        ans = "ABC";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int get(vector<int>& cmp, int u) {
	if(cmp[u] != u) cmp[u] = get(cmp, cmp[u]);
	return cmp[u];
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	int n, m;
	cin >> n >> m;
	vector<int> cmp(n);
	iota(cmp.begin(), cmp.end(), 0);
	
	for(int i = 0, u, v; i < m; i++) {
		cin >> u >> v;
		u--, v--;
		u = get(cmp, u);
		v = get(cmp, v);
		if(u != v) cmp[u] = v;
	}

	map<int, int> mp;
	for(int i = 0; i < n; i++) mp[get(cmp, i)]++;
	int ans = 0;
	for(auto el: mp) ans = max(ans, el.se);
	cout << ans << '\n';
}



Measured memory_bytes: 13520
import sys

#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n=input1()
A=input_array()
if 0 in A:
	print(0)
	sys.exit()
ans=1

for a in A:
	ans=ans*a
	if ans > 10**18:
		break

if ans > 10**18:
	print(-1)
else:
	print(ans)


Measured memory_bytes: 21592
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/



void Calc() {

  ll n, m;
  in, n, m;

  if (n < m / 2) {
    ll tmp = n + ((m / 2) - n) / 2;
    m -= (m / 2 - n) / 2;
    n = tmp;
  }
  err(n, m);
  ll ans = min(n, m / 2);
  cout << (ans) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) std::cout << (#x) << " is " << (x) << std::endl
#define print(x) std::cout << (x) << std::endl
#define println std::cout << std::endl;
using LL = long long;
#define lrt rt << 1
#define rrt rt << 1 | 1
#define lson l, m, lrt
#define rson m + 1, r, rrt
const int N = 3e5 + 2;
int mx[N * 4];

void update(int p, int val, int l, int r, int rt) {
	mx[rt] = std::max(mx[rt], val);
	if (l == r) return;
	int m = (l + r) >> 1;
	if (p > m) update(p, val, rson);
	else update(p, val, lson);
}
int query(int L, int R, int l, int r, int rt) {
	if (L <= l && R >= r) return mx[rt];
	int m = (l + r) >> 1;
	int ans = 0;
	if (L <= m) ans = std::max(ans, query(L, R, lson));
	if (R > m) ans = std::max(ans, query(L, R, rson));
	return ans;
}
int main() {
	//freopen("in","r",stdin);
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n, k;
	std::cin >> n >> k;
	for (int i = 0, x; i < n; ++i) {
		std::cin >> x;
		++x;
		int now = query(x - k, x + k, 1, N, 1);
		update(x, now + 1, 1, N, 1);
	}
	print(mx[1]);
	return 0;
}

Measured memory_bytes: 7756
dp = [0 for i in range(100)]
dp[6] = 1
dp[3] = 1
for i in range(100):
  if i>=4 and dp[i-4]==1:
    dp[i] = 1
  if i>=7 and dp[i-7]==1:
    dp[i] = 1
if dp[int(input())-1]==1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int a,b,k; cin >> a >> b >> k;
    for(int i=a; i <= min(b, a + k - 1); i++) printf("%d\n", i);
    for(int i=max(b - k + 1, a + k); i <= b; i++) printf("%d\n", i);
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=4e5+10;
long long dep[N];
int he[N],ne[N],t[N],cc[N],si[N],tot=0,n,root,sta;
void ad(int x,int y,int z)
{
	tot++;
	ne[tot]=he[x];
	he[x]=tot;
	t[tot]=y;
	cc[tot]=z;
}
void fr(int x,int fa)
{
	int i=he[x],blan=0;
	si[x]=1;
	while (i)
	{
		if (t[i]==fa)
		{
			i=ne[i];
			continue;
		}
		fr(t[i],x);
		si[x]=si[x]+si[t[i]];
		blan=max(blan,si[t[i]]);
		i=ne[i];
	}
	blan=max(blan,n-si[x]);
	if (blan<sta) 
	{
		root=x;
		sta=blan;
	}
}
void dfs(int x,int fa)
{
	int i=he[x];
	si[x]=1; 
	while (i)
	{
		if (t[i]==fa)
		{
			i=ne[i];
			continue;
		} 
		dep[t[i]]=dep[x]+cc[i];
		dfs(t[i],x);
		si[x]=si[x]+si[t[i]];
		i=ne[i];
	}
}
int main()
{
	//freopen("test.in","r",stdin);
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		ad(x,y,z);
		ad(y,x,z); 
	}
	sta=1e9+7;
	fr(1,0);
	dfs(root,0);
	long long ans=0;
	for (int i=1;i<=n;i++) ans=ans+dep[i];
	int i=he[root],num=1e9+7;
	while (i)
	{
		if (si[t[i]]==(n+1)/2) num=min(num,cc[i]);
		i=ne[i];
	}
	if (num==1e9+7) 
	{
		int i=he[root];
		while (i)
		{
			num=min(num,cc[i]);
			i=ne[i];
		}
	}
	ans=ans*2-num;
	printf("%lld\n",ans);
}

Measured memory_bytes: 13184
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		//StringBuffer str = new StringBuffer(hoge1);
		//for(int i=0;i<N;i++) {}
		
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		double A=sc.nextInt();
		double B=sc.nextInt();
		double H=sc.nextInt();
		double M=sc.nextInt();
		
		
		
		double t2=H*30+M/2;
		double t1=6*M;
		//p(t1+" "+t2);
		//p(Math.min(360-Math.abs(t2-t1), Math.abs(t2-t1)));
		double cos=Math.min(360-Math.abs(t2-t1), Math.abs(t2-t1));
		double ans=A*A+B*B-2*A*B*Math.cos(Math.toRadians(cos));
		ans=Math.pow(ans, 0.5);
		p(ans);
	}
		
		
		
		
		
	
	
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 35984
s = input()
t = input()
n = len(s)
m = len(t)
max_cnt = 0
for i in range(n - m + 1):
    cnt = 0
    u = s[i:i + m]
    for j in range(m):
        if t[j] == u[j]:
            cnt += 1
    max_cnt = max(max_cnt, cnt)
print(m - max_cnt)

Measured memory_bytes: 9128
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

vector<long long> getPrimes(long long n)
{
    vector<long long> primes;
    long long d = 2;

    if(n == 1) {
        return primes;
    }

    while(d * d <= n)
    {
        if(n % d == 0)
        {
            primes.push_back(d);
            n /= d;
        }
        else
        {
            ++d;
        }
    }

    primes.push_back(n);

    primes.erase(unique(primes.begin(), primes.end()), primes.end());

    return primes;
}

int main()
{
    long long a, b;
    int ans = 0;
    vector<long long> aPrimes, bPrimes;

    cin >> a >> b;

    aPrimes = getPrimes(a);
    bPrimes = getPrimes(b);

    for(auto aPrime : aPrimes)
    {
        for(auto bPrime : bPrimes)
        {
            if(aPrime == bPrime)
            {
                ++ans;
            }
        }
    }

    cout << ans + 1 << endl;
}

Measured memory_bytes: 256
from collections import deque

def bfs():
    #移動距離　最小値に更新していく
    d = [[float("inf")] * C for _ in range(R)]

    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    que = deque([])
    que.append((sy, sx))
    d[sy][sx] = 0

    while que:
        p = que.popleft()
        if p[0] == gy and p[1] == gx:
            break

        for i in range(4):
            nx = p[1] + dx[i]
            ny = p[0] + dy[i]

            if 0<=nx<C and 0<=ny<R and maze[ny][nx] != "#" and d[ny][nx] == float("inf"):
                #全周を超えない　&　壁でない　&　未探索である
                que.append((ny, nx))
                d[ny][nx] = d[p[0]][p[1]] + 1

    return d[gy][gx]

R, C = map(int,input().split())
sy, sx = 0, 0
gy, gx = R-1, C-1

maze = [list(input()) for _ in range(R)]

cnt = 0
for m in maze:
    cnt += m.count(".")

if cnt-bfs()-1 >= 0:
    print(cnt-bfs()-1)
else:
    print(-1)


    

Measured memory_bytes: 3436
#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>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {
    int N;
    cin >> N;
//    string S;
//    cin >> S;
    if (N >= 30) {
        cout << "Yes" << endl;
        return;
    }
    cout << "No" << endl;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3100