akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
        cout << '\n';
    }
};

void prog()
{
    input in;
    output out;
    std::string s, t, u;
    int a, b;
    in >> s, t, a, b, u;
    if (u == s)
        --a;
    else
        --b;

    out(a, b);
}

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


Measured memory_bytes: 256
fun main(args: Array<String>){
    val k = readLine()!!.toLong()
    val a = LongArray(50)
    for(i in a.indices){
        a[i] = i + 1L
    }
    repeat((50 - k % 50).toInt()){
        val maxIndex = a.indexOf(a.max()!!)
        for(i in a.indices){
            if(i == maxIndex){
                a[i] = a[i] - 50
            }else{
                a[i] = a[i] + 1
            }
        }
    }
    for(i in a.indices){
        a[i] = a[i] + k / 50
    }
    println(50)
    println(a.joinToString(separator = " "))
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

ll mod(ll x){
	return x%MOD;
}

vector<ll> par(100001);//親
vector<ll> Rank(100001);//木の深さ

void init(ll n){//初期化
	rep1(i,n){
		par[i]=i;
		Rank[i]=0;
	}
}

ll find(ll x){
	if(par[x]==x){
		return x;
	}
	else {
		return  par[x]=find(par[x]);
	}
}
void unite(ll x,ll y){
	x=find(x);
	y=find(y);
	if(x==y) return;

	if(Rank[x]<Rank[y]){
		par[x]=y;
	}
	else{
		par[y]=x;
		if(Rank[x]==Rank[y]) Rank[x]++;
	}
}
bool same(ll x,ll y){
	return find(x)==find(y);
}

//a,b x
int main(){
	ll N,M; cin>>N>>M;
	
	init(N);

	rep(i,M){
		ll x,y,z; cin>>x>>y>>z;
		if(!same(x,y)) unite(x,y);
	}

	ll cnt=0;
	rep1(i,N){
		if(i==par[i]) cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
	
	void run() {
		String s = sc.nextLine();
		String t = sc.nextLine();
		
		Map<Character,List<Integer>> next = new HashMap<Character,List<Integer>>();
		for(int i = 0 ; i < s.length(); i++) {
			char ch = s.charAt(i);
			next.computeIfAbsent(ch, c -> new ArrayList<Integer>()).add(i);
		}
		
		long rep = 0;

		int pos = 0;
		for(char ch : t.toCharArray()) {
			
			List<Integer> list = next.get(ch);
			if(list == null) {
				System.out.println(-1);
				return;
			}
			
			int ip = Collections.binarySearch(list, pos);
			if(ip < 0) {
				ip = -ip-1;
			}
			if(ip == list.size()) {
				rep++;
				ip = 0;
			}
			
			pos = list.get(ip)+1;
		}
		System.out.println(rep*s.length() + pos);
		
	}
}


Measured memory_bytes: 36744
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a,b,c;
vector<int> v;
main()
{
	cin>>a>>b>>c;
	v.push_back(a);
	v.push_back(b);
	v.push_back(c);
	sort(v.begin(),v.end());
	cout<<v[0]+v[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c,x[3],i,min;
    scanf("%d %d %d",&a,&b,&c);
    x[0]=a+b;  
    x[1]=b+c;
    x[2]=c+a;
    min=x[0];
    for(i=0; i<=2; i++){
        if(x[i]<min){
            min=x[i];
        }
    } 
    
    printf("%d\n",min);
    return 0;
}

Measured memory_bytes: 128
n=int(input())
deck=list(range(1,2*n+1))
m=int(input())
for mm in range(m):
    method=int(input())
    if method==0:
        d1=deck[0:n]
        d2=deck[n:2*n]
        deck=[]
        for j in range(n):
            deck.append(d1[j])
            deck.append(d2[j])
    elif method>0:
        d1=deck[0:method]
        d2=deck[method:2*n]
        deck=[]
        deck.extend(d2)
        deck.extend(d1)
for c in deck:
    print(c)


Measured memory_bytes: 5624
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
A, B, X = ri_()
print('YES' if A <= X <= A + B else 'NO')

Measured memory_bytes: 64620
#include <iostream>			
#include <vector>			
			
int main(){			
	int n;		
    std::cin >>n;

	int max;
    std::cin >> max;

    int val;
	int count = 1;			
	for(int i = 1; i < n; ++i){		
		std::cin >> val;	

		if(max <= val){	
			++count;
			max = val;
		}	
	}		

	std::cout << count << std::endl;		
			
	return 0;		
}			


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

int main() {
    int h, w;
    cin >> h >> w;
    char grid[2020][2020];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> grid[i][j];
        }
    }

    int left[2020][2020] = {0}, right[2020][2020] = {0}, up[2020][2020] = {0}, down[2020][2020] = {0};
    int cnt = 0;
    //left
    for (int i = 0; i < h; i++) {
        cnt = 0;
        for (int j = 0; j < w; j++) {
            if (grid[i][j] == '#') {
                cnt = 0;
                continue;
            }
            cnt++;
            left[i][j] = cnt;
        }
    }
    //right
    for (int i = 0; i < h; i++) {
        cnt = 0;
        for (int j = w - 1; j >= 0; j--) {
            if (grid[i][j] == '#') {
                cnt = 0;
                continue;
            }
            cnt++;
            right[i][j] = cnt;
        }
    }
    //up
    for (int j = 0; j < w; j++) {
        cnt = 0;
        for (int i = 0; i < h; i++) {
            if (grid[i][j] == '#') {
                cnt = 0;
                continue;
            }
            cnt++;
            up[i][j] = cnt;
        }
    }
    //down
    for (int j = 0; j < w; j++) {
        cnt = 0;
        for (int i = h - 1; i >= 0; i--) {
            if (grid[i][j] == '#') {
                cnt = 0;
                continue;
            }
            cnt++;
            down[i][j] = cnt;
        }
    }

    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (grid[i][j] == '#') continue;
            ans = max(ans, left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 67968
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
const int siz = 1e6 + 5;
const int mod = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;
ll MAX = 1000000000+7;
 
using namespace std;
 
ll modF(ll a) {
    if (a<0) return modF((a%MAX)+MAX);
    else return (a%MAX);
}

void solve(){
  ll n, k, i, a, po=0, ni=0, ans=1;
  vector<ll> vcp, vcn;
  cin >> n >> k;
  for (i=0;i<n;i++) {
      cin >> a;
      if (a<0) {
          a=-a;
          ni++; vcn.push_back(a);
      }
      else {
          po++; vcp.push_back(a);
      }
  }
  if (po>0) sort(vcp.begin(),vcp.end());
  if (ni>0) sort(vcn.begin(),vcn.end());

  if (po==0) {
      if (k%2==0) {
          for (i=0;i<k;i++) {
              ans = ans * (-vcn[ni-1]);
              ans = modF(ans);
              ni--;
          }
      }
      else {
          for (i=0;i<k;i++) {
              ans = ans * (-vcn[i]);
              ans = modF(ans);
          }
      }
  }
  else if (ni==0) {
      for (i=0;i<k;i++) {
          ans = ans * vcp[po-1];
          ans = modF(ans);
          po--;
      }
  }
  else {
      if (k%2==1) {
          ans = vcp[po-1];
          po--; k--;
      }
      while (k>1 && (po>=2 || ni>=2)) {
          ll propo = 0;
          if (po>=2) propo = vcp[po-1]*vcp[po-2];
          ll proni = 0;
          if (ni>=2) proni = vcn[ni-1]*vcn[ni-2];

          if (propo>proni) {
              propo = modF(propo);
              ans = ans*propo;
              ans = modF(ans);
              po = po-2;
          }
          else {
              proni = modF(proni);
              ans = ans*proni;
              ans = modF(ans);
              ni = ni-2;
          }
          k=k-2;
      }
      while (k>0) {
          if (po>0) {
              ans = ans*vcp[po-1];
              ans = modF(ans);
              po--; k--;
          }
          else if (ni>0) {
              ans = ans*(-vcn[ni-1]);
              ans = modF(ans);
              ni--; k--;
          }
      }
  }
  cout << ans << endl;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  // cin >> t;
  while(t--){
    //tt++;
    //cout << "Case #" << tt << ": ";
    solve();
  }
  return 0;
}  

Measured memory_bytes: 5492
N = int(input())
dp = [10**6]*(N+1)
dp[0] = 0
pow6=1
for i in range(N):
    pow6=1
    pow9=1
    while pow6+i <=N: 
        dp[i+pow6] = min(dp[i+pow6],dp[i]+1)
        pow6 = pow6*6
    while pow9+i <=N:
        dp[i+pow9] = min(dp[i+pow9],dp[i]+1)
        pow9 = pow9*9
print(dp[N])

Measured memory_bytes: 42860
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

S = input()

red = 0
ble = 0

for s in S:
    if s == '0':
        red += 1
    else:
        ble += 1

ans = min(red, ble)*2
print(ans)

Measured memory_bytes: 12184
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
const int maxn=2222;
const ll modn=1e9+7;
const int inf=2e9+7;
const double PI = acos(-1.0);
const double eps=1e-8;
inline int lowbit(int x){return x&-x;}
inline ll lowbit(ll x) {return x&-x;}
inline int CountOneBinary(ll num){int ans=0;while(num){if(num&1) ans+=1;num>>=1;}return ans;}
inline void read(int &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline void read(ll &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline ll qpow(ll x,ll y){ll ans=1;while(y){if(y&1) ans=ans*x%modn;x=x*x%modn;y>>=1;}return ans;}
inline double qpow(double x,ll y){double ans=1;while(y){if(y&1) ans=ans*x;x=x*x;y>>=1;}return ans;}
int main()
{
    char s[100];
    while(scanf("%s",s)!=EOF)
    {
        for(int i=0;s[i];i++)
        {
            if(s[i]=='9') putchar('1');
            else putchar('9');
        }
        putchar('\n');
    }
}


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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    REP(i, n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    vector<ll> cc(n);
    for(int i = 0; i < n; i++){
        auto index = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
        cc[i] = (ll)(n - index);
    }

    for(int i = n-2; i >= 0; i--) cc[i] += cc[i+1];

    ll ans = 0ll;

    for(int i = 0; i < n; i++){
        int l = a[i];
        auto index = upper_bound(b.begin(), b.end(), l) - b.begin();
        if(index == n) continue;
        ans += (ll)cc[index];
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 2176
#include <bits/stdc++.h>
    using namespace std;
     
    int main()
    {   
        ios_base::sync_with_stdio(0);
        cin.tie(0);         
        
        int n,x,c=0,sum=0;
        cin>>n>>x;
        for(int d,i=1;i<=n;i++){ 
            cin>>d;
            sum+=d;
            if(sum<=x)c++;
        }
        cout<<c+1<<endl; 
                    
     
        return 0;
    }

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int par[10000];
int rank[10000];
void init(int n) {
    for (int i=0; i<n; i++) {
        par[i]=i;
        rank[i]=0;
    }
}
int find(int x) {
    if (par[x]==x) {
        return x;
    } else {
        return par[x]=find(par[x]);
    }
}
void unite(int x, int y) {
    x=find(x);
    y=find(y);
    if (x==y) return;
    if (rank[x]<rank[y]) {
        par[x]=y;
    } else {
        par[y]=x;
        if (rank[x]==rank[y]) rank[x]++;
    }
}
bool same(int x, int y) {
    return find(x)==find(y);
}

struct point { int x, y; };
struct edge {
    int u, v;
    double cost;
};
bool comp(const edge& e1, const edge& e2) {
    return e1.cost>e2.cost;
}
double dist(point p1, point p2) {
    return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
point p[10000];
vector<edge> es;
int main() {
    int n, m;
    scanf("%d%d",&n,&m);
    init(n);
    for (int i=0; i<n; i++) scanf("%d%d",&p[i].x,&p[i].y);
    double all=0.0;
    for (int i=0; i<m; i++) {
        int s, e; scanf("%d%d",&s,&e);
        edge ne=(edge){s-1,e-1,dist(p[s-1],p[e-1])};
        es.push_back(ne);
        all+=ne.cost;
    }
    sort(es.begin(), es.end(), comp);
    double res=0.0;
    for (int i=0; i<m; i++) {
        edge e=es[i];
        if (!same(e.u,e.v)) {
            unite(e.u, e.v);
            res+=e.cost;
        }
    }
    printf("%.3f\n",all-res);
}

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

int main() {
int n;
string s;
cin >> n >> s;
int ans = 0;
for(int i = 0; i <= n - 3; i++) {
if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
}
cout << ans << endl;
return 0;
}

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

int main(){
  int N;
  cin >> N;
  int A1[N];
  int A2[N];
  for(int i=0;i<N;i++) cin >> A1[i];
  for(int i=0;i<N;i++) cin >> A2[i];
  
  // 本当は累積和でもっと高速化できる
  int ans = 0;
  for(int i=0;i<N;i++){
    int score = 0;
    for(int j=0;j<=i;j++) score += A1[j];
    for(int j=i;j<N;j++) score += A2[j];
    ans = max(ans, score);
  }
  
  cout << ans;
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC140A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(n * n * n);
        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#define N 100005
using namespace std;
int a[N], n, ans;
inline int read() {
    int x = 0; bool flag = 0; char c = getchar();
    while(c < '0' || c > '9'){if(c=='-') flag = 1; c = getchar();}
    while(c >= '0' && c <= '9') {x = x*10 + c-48; c = getchar();}
    if(flag) x = -x;
    return x;
}

int main() {
    int j, cnt;
    n = read();
    for(int i = 1; i <= n; i++) 
        a[i] = read();
    sort(a+1, a+1+n);
    for(int i = 1; i <= n; i++) {
        cnt = 0;
        for(j = i; j <= n; j++)
            if(a[j] == a[i]) 
                cnt ++;
            else break;
        if(cnt < a[i]) ans += cnt;
        else if(cnt > a[i]) ans += cnt - a[i];
        i = j-1;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define dump(x) cerr << #x << " : " << x << '\n'

int main() {
    int K, X;
    cin >> K >> X;
    int a = X - K + 1;
    int b = X + K - 1;
    while(a <= b) {
        cout << a << " ";
        a++;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
using vi  = vector<int>;
using ii  = pair<int,int>;
using vii = vector<ii>;
using ll  = long long;

typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) int((x).size())
#define REP(i, a, b) for (auto (i) = (a); (i) <= (b); (i)++)
#define PER(i, a, b) for (auto (i) = (a); (i) >= (b); (i)--)
#define ITR(i, x) for (auto (i) = (x).begin(); (i) != (x).end(); (i)++)

string to_string(string s) { return '\"' + s + '\"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A,B> p)
{ return "(" + to_string(p.F) + ", " + to_string(p.S) + ")"; }
template <typename T> string to_string(T v) {
	int f = 0; string res = "{";
	for (const auto &x: v)
		res += (f++ ? ", " : "") + to_string(x);
	return res + "}";
}
void debug_out() { cerr << "]\n"; }
template <typename T, typename... V>
void debug_out(T a, V... v)
{ cerr << to_string(a); if (sizeof...(v)) cerr << ", "; debug_out(v...); }

#ifdef LOCAL // add -DLOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = [", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif // debug(var1, var2, ...);

const int N = 1e2;
int a[N+5];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int n; cin >> n;
	REP(i, 1, n)
		cin >> a[i];
	int ans = 0;
	REP(i, 1, n)
	{
		if (i % 2 == 1 and a[i] % 2 == 1)
			ans++;
	}
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3652
n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(0,n-2):
  if (p[i]<p[i+1] and p[i+1]<p[i+2]) or (p[i]>p[i+1] and p[i+1]>p[i+2]):
    count+=1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int r, c, k;
	cin >> r >> c >> k;
	
	vvi a(r, vi(c, 0));
	vector<vector<vector<ll>>> dp(r, vector<vector<ll>>(c, vector<ll>(4, 0)));
	
	for(int i = 0; i < k; i++) {
		int rg, cg, v;
		cin >> rg >> cg >> v;
		rg--; cg--;
		
		a[rg][cg] = v;
	}
	
	dp[0][0][0] = 0;
	if(a[0][0]) dp[0][0][1] = a[0][0]; 
	for(int i = 0; i < r; i++) {
		for(int j = 0; j < c; j++) {
			for(int taken = 0; taken < 4; taken++) {
				if(i + 1 < r) dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][taken]);
				if(i + 1 < r) if(a[i + 1][j]) dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][taken] + a[i + 1][j]);
				if(j + 1 < c) dp[i][j + 1][taken] = max(dp[i][j + 1][taken], dp[i][j][taken]);
				if(j + 1 < c) if(taken < 3) if(a[i][j + 1]) dp[i][j + 1][taken + 1] = max(dp[i][j + 1][taken + 1], dp[i][j][taken] + a[i][j + 1]);
			}
		}
	}
	
	cout << max({dp[r - 1][c - 1][0], dp[r - 1][c - 1][1], dp[r - 1][c - 1][2], dp[r - 1][c - 1][3]}) << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 671708
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    a = inputIntList()
    ans = 0
    look = 1
    for i in a:
        if look == i:
            look += 1
        else:
            ans += 1

    return ans if ans != N else -1


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


Measured memory_bytes: 26140
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		char c;
		int k=s[i]-'0'+n;
		if(k>42)
			c=s[i]+n-26;
		else
			c=s[i]+n;
		cout<<c;
	}
} 

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
					/*多倍長整数/cpp_intで宣言
					#include <boost/multiprecision/cpp_int.hpp>
					using namespace boost::multiprecision;
					*/

#pragma gcc target ("avx2")
#pragma gcc optimization ("o3")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}
#define nof(T) [](T a){return a;}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	map<string, int> a;
	string s;
	int maxa = -1;
	rep(i, n) {
		scans(s);
		++a[s];
		maxa = max(a[s], maxa);
	}
	for (auto aa : a) {
		if (aa.second == maxa)prints(aa.first);
	}

	Please AC;
}


Measured memory_bytes: 17664
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long

int cmpcrois (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}

int cmpdecr (const void * a, const void * b) {
   return ( *(int*)b - *(int*)a );
}


int main()
{
   int N , M;
   scanf("%d %d",&N,&M);

   int X[M];
   int count = 0;

   for (int i = 0;i<M;i++)
   {
       scanf("%d",&X[i]);
   }

   int D[M];

 qsort(X, M, sizeof(int), cmpcrois);

  for (int i = 0;i<M-1;i++)
   {
       D[i]=X[i+1]-X[i];
   }

 qsort(D, M-1, sizeof(int), cmpdecr);

 for (int i = N-1 ;i<M-1;i++)
   {
       count+=D[i];
   }

   printf("%d",count);

    return 0;

}


Measured memory_bytes: 1268
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

//ex
LL calc(vector<LL>& A,LL X){
	int size = A.size();
	LL ans = 0;
	for(int i=0;i<size;++i){
		ans += (A[i]-X)*(A[i]-X);
	}
	return ans;
}

void solve(){
	int N;
	cin >> N;
	vector<LL> A(N);
	LL sum = 0;
	for(int i=0;i<N;++i){
		cin >> A[i];
		sum += A[i];
	}
	LL ave = sum/N;
	LL L,R;
	L = calc(A,ave);
	R = calc(A,ave+1);
	cout << min(L,R) << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll,ll>
#define PP pair<P,P>
using namespace std;

int main(){
    int h,m,h2,m2,k; cin >> h >> m >> h2 >> m2 >> k;
    int times=h2-h;
    int mi=m2-m;
    if(mi>=0) cout << max(0,times*60+mi-k) << endl;
    else cout << max(0,times*60+mi-k) << endl;
return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main() 
{
  double x1,x2,y1,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double distance;
  distance = pow((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2),0.5);
  printf("%lf\n",distance);
  return 0;
}


Measured memory_bytes: 3400
#include <stdio.h>

char N[271828];

int main(void) {
	int i, asumisu = 0;
	if (scanf("%271827s", N) != 1) return 1;
	for (i = 0; N[i] != '\0'; i++) {
		asumisu = (asumisu + (N[i] - '0')) % 9;
	}
	puts(asumisu == 0 ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 1780
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

using ll =  long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}
}


int main() {

	ll n, k, s;
	std::cin >> n >> k >> s;

	for (int i = 0; i < n - k; ++i) {
		if (s == 1000000000) std::cout << s - 1 << " ";
		else std::cout << s + 1 << " ";
	}
	rep(i, k)  {
		if (i == k - 1) std::cout << s << std::endl;
		else std::cout << s << " ";
	}

	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int res = 0;
  int n = s.size();
  vector<int> dp(2,0);
  for (int i = 0; i < n; i++) {
    int d = (s[i] - '0');
    vector<int> dp2(2,0);
    for (int c = 0; c < 2; c++) {
      if (i == 0 && c) continue;
      for (int j = 0; j <= (c ? 9 : d); j++) {
        dp2[c | (j < d) ] = max(dp[c] + j, dp2[c | (j < d)]);
      } 
    }
    dp = dp2;
  }
  cout << max(dp[0], dp[1]) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
s=[[]for i in range(N)]
for i in range(N-1):
    a,b=map(lambda x: int(x)-1,input().split())
    s[a].append(b)
    s[b].append(a)
sys.setrecursionlimit(200000)
lf,ls=[None]*N,[None]*N
lf[0]=0
ls[-1]=0
def hu(n,c,l):
    for i in s[n]:
        if l[i]==None:
            l[i]=c
            hu(i,c+1,l)
hu(0,1,lf)
hu(-1,1,ls)
af=0
for i in range(N):
    if lf[i]<=ls[i]:
        af+=1
if af*2>N:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 117296
#include<iostream>
#include<cstring>

using namespace std;

int box[100005];
bool red[100005];

int main(){
    int N, M, ans = 0;
    cin >> N >> M;
    memset(red, 0, sizeof(red));
    for(int i=1; i<=N; i++) box[i] = 1;

    red[1] = 1;
    for(int i=1; i<=M; i++){
        int x, y;
        cin >> x >> y;

        if(red[x]) red[y] = 1;
        box[x]--; box[y]++;
        if(box[x] == 0) red[x] = 0;
    }

    for(int i=1; i<=N; i++){
        if(red[i]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<P> a(n);
  rep(i,n) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(all(a));
  int maxlen = 0; //単調増加列の長さ
  rep(l,n) {
    int r = l+1;
    while (r < n) {
      if (a[r-1].second < a[r].second) r++;
      else break;
    }
    chmax(maxlen, r-l);
    l = r-1;
  }
  cout << n - maxlen << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

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

  sort(a, a + n);

  ll dp[101010];
  ll deathmax = -1;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      dp[i] = a[i];
    } else {
      dp[i] = dp[i - 1] + a[i];
    }
    if (dp[i] * 2 < a[i + 1]) {
      deathmax = i;
    }
  }
  D(n - deathmax - 1);
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      if(a==b&&a==c)System.out.println(1);
      else if(a==b||a==c||b==c)System.out.println(2);
      else System.out.println(3);
    }
}

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

int main() {
  int n, d;
  cin >> n >>d;
  vector<double> x(n);
  vector<double> y(n);
  for(int i=0;i<n;i++){
    cin >> x[i] >> y[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    double a=0;
    a=x[i] * x[i] + y[i] * y[i];
    a=sqrt(a);
    if(a<=d) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6484
#include<stdio.h>
#define N 10000
#define M 101

void guruguru(
    char map[101][101],int n,
    int x,int y,
    int vector,int length,int count){

  if(count>=length-1)
    return;
  else if(vector==8){
    y--;
    if(y<0 || map[y-1][x]=='#'){
      vector=6;
      y++;
      x++;
    }
    map[y][x]='#';
    map[y][x+1]=' ';
    count++;
    guruguru(map,n,x,y,vector,length,count);
    return;
  }
  else if(vector==6){
    x++;
    if(x>=n || map[y][x+1]=='#'){
      vector=2;
      y++;
      x--;
    }
    map[y][x]='#';
    map[y+1][x]=' ';
    count++;
    guruguru(map,n,x,y,vector,length,count);
    return;
  }
  else if(vector==2){
    y++;
    if(y>=n || map[y+1][x]=='#'){
      vector=4;
      y--;
      x--;
    }
    map[y][x]='#';
    map[y][x-1]=' ';
    count++;
    guruguru(map,n,x,y,vector,length,count);
    return;
  }
  else if(vector==4){
    x--;
    if(x<0 || map[y][x-1]=='#'){
      vector=8;
      x++;
      y--;
    }
    map[y][x]='#';
    map[y-1][x]=' ';
    count++;
    guruguru(map,n,x,y,vector,length,count);
    return;
  }
}

int main(void){
  int i,j,k;
  int d,n[N];
  char map[M][M];
  int sx,sy,vector,length,count;

  scanf("%d",&d);
  for(i=0;i<d;i++){
    scanf("%d",&n[i]);
  }
  for(i=0;i<d;i++){
    for(j=0;j<n[i];j++){
      for(k=0;k<n[i];k++){
        map[j][k]=0;
      }
    }
    sx=0;
    sy=n[i]-1;
    vector=8;
    map[sy][sx]='#';
    map[sy][sx+1]=' ';
    length=1;
    for(j=2;j<=n[i];j++){
      length+=j;
      if(j%2!=0)
        length++;
    }
    count=0;
    guruguru(map,n[i],sx,sy,vector,length,count);
    for(j=0;j<n[i];j++){
      for(k=0;k<n[i];k++){
        printf("%c",map[j][k]);
      }
      printf("\n");
    }
    if(i<d-1)
      printf("\n");
  }

  return 0;
}

Measured memory_bytes: 0
def divisors(N):
    U = int(N ** 0.5) + 1
    L = [i for i in range(1, U) if N % i == 0]
    return L + [N // i for i in reversed(L) if N != i * i]

def solve(k):
    n = N
    while n % k == 0:
        n //= k
    return (n % k == 1)

N = int(input())

K = set(divisors(N) + divisors(N - 1)) - {1}
print(sum(solve(k) for k in K))

Measured memory_bytes: 40300
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
using ll=long long;
using Vec = vector<ll>;
using P = pair<ll, ll>;
using VecP = vector<P>;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)
//static const ll MOD = 1000000007;
//static const ll INF = 1000000000000000000;
//#define PI 3.14159265358979323846

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int countDivisorNum(int n) {
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            count++;
        }
    }
    return count;
}

int main() {
    ll x[5];
    cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

    rep(i, 5, 0) {
        if (x[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>	
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 2000000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
int lcm(int a,int b){if(a==0){return b;} return a/gcd(a,b)*b;}

int n;
#define MAX 55
int l[MAX];

int dp[MAX];

signed main(){
	cin>>n; 
	int sum=0;
	for(int i=1; i<=n; i++){ 
		cin>>l[i];
		sum+=l[i];
	}
	
	int ans=INF;
	for(int i=1; i<=n; i++){
		for(int j=i; j<=n; j++){
			int cnt=0;
			for(int k=i; k<=j; k++){
				cnt+=l[k];
			}
			fill(dp, dp+n+1, INF);
			if(sum==cnt) continue;
			dp[0]=cnt;
			for(int k=1; k<=n; k++){
				int c=0;
				for(int f=k; f>=1; f--){
					c+=l[f];
					if(k==n&&f==1) continue;
					if(c>=cnt){
						int a=max(c, dp[f-1]);
						dp[k]=min(dp[k], a);
					}
				}
			}
			ans=min(ans, dp[n]-cnt);
		}
	}
	cout<<ans<<en;
}



Measured memory_bytes: 3104
#ifdef DEBUG
#include "../utils.cpp"
#endif
#include <bits/stdc++.h>
/*
Problem
 
Category
DP
 
URL:
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_A&lang=ja

考察:
0-1 ナップサック問題。使えるのは1回だけ。
dp[i][w] = 重さw以下でi番目までの品物を使ったときの価値の最大値
dp[i][w] = max(dp[i-1][w], dp[i-1][w-w_i]+ v_i)
O(N*W)

Date: 2020/04/18
*/
 

using namespace std;
using ll = int64_t;
#define int int64_t

 
/* ==== declarations ====== */
// functions
void solve();
void getInput();
 
// global variables
int N, W;
vector<vector<int>> dp;
vector<int> V;
vector<int> Weights;

/* ======================== */

void getInput() {
    cin>>N>>W;
    V = vector<int>(N, 0);
    Weights = vector<int>(N, 0);
    
    for(int i=0; i<N; ++i) {
        cin>>V[i]>>Weights[i];
    }
}
 
 
void solve() {
    dp = vector<vector<int>>(N, vector<int>(W+1, 0));
    for(int j=Weights[0]; j<W+1; ++j) dp[0][j] = V[0];
    for(int i=1; i<N; ++i) {
        for(int j=0; j<W+1; ++j) {
            if (j-Weights[i] < 0) dp[i][j] = dp[i-1][j];
            else dp[i][j] = max(dp[i-1][j], dp[i-1][j-Weights[i]]+V[i]);
        }
    }
    cout<<dp[N-1][W]<<endl;
    
}
 
 
 
signed main(){
    getInput();
    solve();
    return 0;
}




Measured memory_bytes: 10784
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
#define rp
#define pi 	3.14159265358979323846
#define M 1000000
/*
was buried because of depression
     now time to rise up
        music is life
*/

//bruteforce to check prime
/*bool checkprime(ll j)
{
    if(j<=1)
        return false;
    else if(j==2)
        return true;
    else if(j%2==0)
        return false;
    else
    {
        bool prime=true;
        int divisor=3;
        int upperlimit=sqrt(j)+1;
        while(divisor<=upperlimit)
        {
            if(j%divisor==0)
                return false;
            divisor+=2;
        }
        return prime;
    }
}*/
/*int main()
{
    int n,a,i,c=0;
    vector<int>v;
    cin>>n;
    while(n--)
    {
        cin>>a;
        v.pb(a);

    }
    sort(v.begin(),v.end());
    int min=v[0];
    int max=v[n-1];
    for(i=0; i<v.size(); i++)
    {

        if(v[i]>min && v[i]<max)
            c++;

    }
    cout<<c<<endl;

    return 0;
}*/
/*bool prime[M];
bool isprime(ll n)
{
    if(n<2)return false;
    if(n==2)return true;
    if(n%2==0)return false;
    return prime[n]==false;
}
bool seive(ll n)
{
    for(int i=3;i*i<=n;i+=2)
    {
        if(prime[i]==false)
        {
            for(int j=i*i;j<=n;j+=i)
                prime[j]=true;
        }

    }
}*/

int main()
{
int i,j,n;
cin>>n;
string s,r,t;
cin>>s;
r=s.substr(0,n/2);
t=s.substr(n/2,n-1);
if(s.size()==1)
    cout<<"No"<<endl;
else
{
if(r==t)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;
}

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int N=500;
struct ANS {
    int a,b,c,d;
    ANS(int x,int y,int z,int w):a(x),b(y),c(z),d(w) {};
};
vector<ANS> ans;
int r,c;
int val[N+5][N+5];
bool vis[N+5][N+5];
int main() 
{
    scanf("%d%d",&r,&c);
    for(int i=0; i<r; i++)
        for(int j=0; j<c; j++)
            scanf("%d",&val[i][j]),
            val[i][j]&=1;
    for(int i=0; i<r; i++)
        for(int j=0; j<c-1; j++) 
            if(val[i][j])
                val[i][j+1]^=val[i][j],
                ans.push_back(ANS(i+1,j+1,i+1,j+2)); //保存操作
    for(int i=0; i<r-1; i++)
        if(val[i][c-1])
            val[i+1][c-1]^=val[i][c-1],
            ans.push_back(ANS(i+1,c,i+2,c));
    printf("%d\n",ans.size());
    for(int i=0; i<ans.size(); i++)
        printf("%d %d %d %d\n",ans[i].a,ans[i].b,ans[i].c,ans[i].d);
    return 0;
}

Measured memory_bytes: 5232
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == 500*i + 100*j + 50*k:
                cnt += 1
print(cnt)

Measured memory_bytes: 3060
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

constexpr int64_t INF = 1000000000100000;
int32_t N;
int64_t A[2000];
int64_t x;
int64_t dp[2001][2001];

template<typename T>
void fill_all(T& a,const T& b)
{
	a = b;
}
template<typename T, size_t N, typename U>
void fill_all(T(& a)[N], const U& b)
{
	for (auto& i : a) {
		fill_all(i, b);
	}
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N >> x;
	for (int i = 0; i < N; ++i)
	{
		in >> A[i];
	}
	fill_all(dp, INF);
	int64_t min = INF;
	{
		int64_t tmp = 0;
		for (int i = 0; i < N; ++i)
		{
			dp[0][i] = A[i];
			tmp += dp[0][i];
		}
		min = std::min(min, tmp);
	}
	for (int c = 1; c <= N; ++c)
	{
		int64_t tmp = x*c;
		for (int i = 0; i < N; ++i)
		{
			int next = (i-c+N) % N;
			dp[c][i] = std::min(dp[c-1][i], A[next]);
			tmp += dp[c][i];
		}
		min = std::min(min, tmp);
	}

	std::cout << min << endl;

	return 0;
}
#endif


Measured memory_bytes: 32120
#include <stdio.h>
int main(void){
    long long Q, H, S, D, N, m2, m, c;
    scanf("%lld %lld %lld %lld", &Q, &H, &S, &D);
    scanf("%lld", &N);
    
    if (8*Q>4*H) m2=4*H;
    else m2=8*Q;
    if (m2>2*S) m2=2*S;
    if (m2>D) m2=D; 
    
    if (4*Q>2*H) m=2*H;
    else m=4*Q;
    if (m>S) m=S;
    
    c=(N/2)*m2+(N%2)*m;
    
    printf("%lld", c);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;

int main()
{
	ll n, m;
	cin >> n >> m;
	ll res = 0;
	if (m / 2 <= n) cout << m / 2;
	else
	{
		m -= (n * 2);
		res += n + m / 4;
		cout << res;
	}
}

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

int ans[100005];
  
signed main(){
  
  int n;
  cin>>n;

  for(int i=1;i<=n;i++){
    int a;
    cin>>a;
    ans[a] = i;
  }
  
  for(int i=1;i<=n;i++){
    if( i != 1 ) cout<<' ';
    cout<<ans[i];
  }
  
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 1536
package main

import (
	"bufio"
	"fmt"
	"os"
)

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, 100000)
	sc.Buffer(buf, 100000+1024)
	sc.Split(bufio.ScanWords)
	input := readLine(sc)

	var count int
	for i := 0; i < len(input); i++ {
		if i%2 == 0 {
			if input[i] == '0' {
				count++
			}
		} else {
			if input[i] == '1' {
				count++
			}
		}
	}

	if count > len(input)/2 {
		fmt.Println(len(input) - count)
	} else {
		fmt.Println(count)
	}
}


Measured memory_bytes: 896