akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)

ll N, M;
ll dels=-1, delt=-1;

double updatedp(vector<vector<ll>> &g,vector<double> &dp,ll v){
	if(v==N-1)return 0.;
	if(dp[v]>-0.1)return dp[v];
	double ans=0.;
	ll gvsize=g[v].size();
	for(ll nextv:g[v]){	
		if(v==dels && nextv==delt){
			gvsize--;
			continue;
		}
		ans+=updatedp(g,dp,nextv);
	}
	return dp[v]=1.+ans/gvsize;
}

signed main() {
  	scanf("%lld%lld", &N, &M);
	vector<vector<ll>> g(N);
	for(ll i=0;i<M;i++){
		ll s,t;
		scanf("%lld%lld", &s, &t);
		s--;t--;
		g[s].push_back(t);
	}

	vector<double> dptmp(N,-1.);
	double ans=updatedp(g,dptmp,0);

	vector<pair<ll,ll>> delpath;
	for(ll v=0;v<N;v++){
		if(g[v].size()==1)continue;
		double maxval=0.;
		ll tmps=-1,tmpt=-1;
		for(ll nextv:g[v]){
			if(maxval<dptmp[nextv]){
				maxval=dptmp[nextv];
				tmps=v;
				tmpt=nextv;
			}
		}
		delpath.push_back({tmps,tmpt});
	}

	for(pair<ll,ll> path:delpath){
		dels=path.first,delt=path.second;
		vector<double> dp(N,-1.);
		double tmp=updatedp(g,dp,0);
		ans=min(ans,tmp);
	}

	printf("%.20f\n", ans);
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	
    int o[100010] = {0};
    int e[100010] = {0};
    // vector<int> o(100010, 0), e(100010, 0);
    // vector<int> o(1e5 + 1, 0), e(1e5 + 1, 0);

	// when changing input process -> result doesn't change
    int a, b;
    for(int i=0;i<n/2;i++){
        cin>>a>>b;o[a]++;e[b]++;
    }
    /*
    rep(i, 1, n)
	{
		int x; cin >> x;
		if (i % 2 == 1) ++o[x];
		else ++e[x];
	}
    */
	int mxO, mxOId, secO, mxE, mxEId, secE;
	mxO = secO = mxE = secE = 0;
    // mxO = secO = mxE = secE = mxOId = mxEId = 0;
	
    rep(i, 0, 100000){
    // for(int i=0;i<=100000;i++){
        if(o[i]>mxO){
            secO=mxO;mxO=o[i];mxOId=i;
        }
        else if(o[i]>secO)
        secO=o[i];
        if(e[i]>mxE){
            secE=mxE;mxE=e[i];mxEId=i;
        }
        else if(e[i]>secE)
        secE=e[i];
    }
    // rep(i, 0, 100005)
    // // rep(i, 0, 100000)
	// {
	// 	if (mxO < o[i])
    //     // if (mxO <= o[i])
	// 	{
	// 		secO = mxO;
	// 		mxO = o[i];
	// 		mxOId = i;
	// 	}
	// 	else if (secO < o[i]);
	// 	{
	// 		secO = o[i];
	// 	}
    //     if (mxE < e[i])
    //     // if (mxE <= e[i])
	// 	{
	// 		secE = mxE;
	// 		mxE = e[i];
	// 		mxEId = i;
	// 	}
	// 	else if (secE < e[i])
	// 	{
	// 		secE = e[i];
	// 	}
	// }

    // output process changed -> result doesn't change
    int ans;
    if(mxEId==mxOId)
    ans=max(secE,secO)+mxE;
    else
    ans=mxE+mxO;
    cout<<n-ans<<endl;
    return 0;
    /*
    if (mxOId != mxEId) cout << n - mxO - mxE << endl;
	else
	{
		int res = max(mxO + secE, secO + mxE);
		cout << n - res << endl;
	}
    */
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#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++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const double PI=3.14159265358979323846;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  vint a(m),b(m);
  set<int> S;
  vint tmp;
  rep(i,m){
    cin>>a[i]>>b[i];
    if(a[i]==1){
      vpush(tmp,b[i]);
    }
    if(b[i]==n){
      S.insert(a[i]);
    }
  }
  rep(i,(int)tmp.size()){
    if(S.find(tmp[i])!=S.end()){
      cout<<"POSSIBLE"<<'\n';
      return(0);
    }
  }
  cout<<"IMPOSSIBLE"<<'\n';
  return(0);
}


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

using namespace std;
typedef unsigned int UINT;
typedef int INT;


int main()
{
	int pattern = 0;
	int A, B, C, X;
	cin >> A >> B >> C >> X;

	for (int i = 0; i <= A; ++i) {
		int remain1 = X - 500 * i;

		if (remain1 < 0) {
			break;
		}

		for (int j = 0; j <= B; ++j) {
			int remain2 = remain1 - 100 * j;

			if (remain2 < 0) {
				break;
			}

			if (remain2 / 50 <= C) {
				pattern += 1;
			}
		}
	}

	cout << pattern << endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
	ll n,k;
	cin >> n >> k;
	vector<ll> p(n);
	rep(i,n) cin >> p[i];
	sort(p.begin(),p.end());
	ll sum=0;
	rep(i,k){
		sum+=p[i];
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 3624
#include<iostream>
#define int long long
const int mod = 1e9 + 7;
using namespace std;
int app(int arr[],int n){
    int sum=0;
    for(int i=0;i<61;i++){
        int zc=0,oc=0;
        int adsum=0;
        for(int j=0;j<n;j++){
            if(arr[j]%2==0){
                zc++;
            }else{
                oc++;
            }
            arr[j]=arr[j]/2;
        }
        adsum = ((oc * zc % mod) * ((1LL << i) % mod)) % mod;
        sum=sum+adsum;
        sum=sum%mod;
    }
    return sum;
}
int32_t main(){
    int n;
    cin>>n;
    int arr[n];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sum=app(arr,n);
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long int m1, m2;

    vector<long long int> x(n);

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

    vector<long long int> s(x);

    sort(s.begin(), s.end());

    m1 = s[n/2];
    m2 = s[(n/2)-1];

    for (int i = 0; i < n; i++) {
        if (x[i] >= m1) {
            cout << m2 << endl;
        }
        else if (x[i] <= m2) {
            cout << m1 << endl;
        }
    }
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int INF = 1e18;
struct Edge{
    int to,money,dist;
};
struct Data{
    int v,money,dist;
};
vector<Edge> g[55];
signed main(){
    int n,m,s;cin >> n >> m >> s;
    rep(i,m){
        int u,v,a,b;cin >> u >> v >> a >> b;
        u--;v--;
        g[u].push_back((Edge){v,a,b});
        g[v].push_back((Edge){u,a,b});
    }
    vector<int> c(n),d(n);
    rep(i,n)cin >> c[i] >> d[i];
    auto comp = [](Data &a,Data &b){
        if(a.dist == b.dist)return a.money < b.money;
        return a.dist > b.dist;
    };
    priority_queue<Data,vector<Data>,decltype(comp)> pq{comp};
    vector<vector<int>> dist(55,vector<int>(2550,INF));
    auto push = [&](int now,int cur,int cost){
        if(cur < 0)return;
        if(dist[now][cur] <= cost)return;
        dist[now][cur] = cost;
        pq.push((Data){now,cur,cost});
    };
    s = min(s,2549ll);
    push(0,s,0);
    while(pq.size()){
        auto tmp = pq.top();pq.pop();
        int v = tmp.v,money = tmp.money,cost = tmp.dist;
        if(dist[v][money] != cost)continue;
        if(money + c[v] < 2550)push(v,money + c[v],cost + d[v]);
        for(auto next:g[v]){
            push(next.to,money - next.money  ,next.dist + cost);
        }
    }
    for(int i = 1;i < n ;i++){
        int tmp = INF;
        rep(j,2510)tmp = min(tmp,dist[i][j]);
        cout << tmp << endl;
    }


    return 0;
}

Measured memory_bytes: 7456
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int N = 202; 

int n, dis[N][N], col[N]; 
char s[N]; 

int dfs(int u, int flag) {
  col[u] = flag; int ret = 1; 
  for(int i = 1; i <= n; i++) {
    if(dis[u][i] != 1) continue ; 
    if(col[i] != -1 && col[i] != (flag ^ 1)) return 0; 
    if(col[i] != -1) continue ; 
    ret &= dfs(i, flag ^ 1); 
  }
  return ret; 
}

void floyd() {
  for(int k = 1; k <= n; k++) 
    for(int i = 1; i <= n; i++)
      for(int j = 1; j <= n; j++) 
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]); 
}

int main () {
  memset(col, -1, sizeof(col)); 
  scanf("%d", &n); 
  for(int i = 1; i <= n; i++) {
    scanf("%s", s + 1); 
    for(int j = 1; j <= n; j++) {
      dis[i][j] = s[j] - '0';  
      if(i == j) dis[i][j] = 0; 
      else if(s[j] == '0') dis[i][j] = 1000000000; 
    }
  }
  if(!dfs(1, 0)) {
    puts("-1"); return 0; 
  }
  floyd();  
  int ans = 0; 
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= n; j++) 
      ans = max(ans, dis[i][j]); 
  }
  printf("%d\n", ans + 1); 
  return 0; 
}


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


int main() {
  string str;

  cin >> str;

  int count=0;
  if(!(str.at(0)=='C')){
    count++;
  }
  if(!(str.at(1)=='O')){
    count++;
  }
  if(!(str.at(2)=='D')){
    count++;
  }
  if(!(str.at(3)=='E')){
    count++;
  }
  if(!(str.at(4)=='F')){
    count++;
  }
  if(!(str.at(5)=='E')){
    count++;
  }
  if(!(str.at(6)=='S')){
    count++;
  }
  if(!(str.at(7)=='T')){
    count++;
  }
  if(!(str.at(8)=='I')){
    count++;
  }
  if(!(str.at(9)=='V')){
    count++;
  }
  if(!(str.at(10)=='A')){
    count++;
  }
  if(!(str.at(11)=='L')){
    count++;
  }
  if(!(str.at(12)=='2')){
    count++;
  }
  if(!(str.at(13)=='0')){
    count++;
  }
  if(!(str.at(14)=='1')){
    count++;
  }
  if(!(str.at(15)=='6')){
    count++;
  }

  cout << count <<endl;

}

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

using namespace std;

#define ll long long




void solve() {

	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int sortedArr[n]; 
	copy(arr, arr + n, sortedArr);
	partial_sort(sortedArr, sortedArr + 2, sortedArr + n, greater<int>());
	for(int i = 0; i < n; i++) {
		if(arr[i] == sortedArr[0]) {
			cout << sortedArr[1] << "\n";
		}
		else {
			cout << sortedArr[0] << "\n";
		}
	}

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 5172
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# from fractions import gcd
# input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

k = inp()

keta = len(str(k))
ans = -1
tmp = 0
for i in range(1000001):
    tmp = ((tmp + (7 * pow(10,i,k)) % k)) % k
    if tmp == 0:
        ans = i+1
        break

print(ans)

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

int main()
{
	int N;
	cin >> N;
	int A[2][N];
	for (int i = 0; i < 2; ++i)
	{
		for (int j = 0; j < N; ++j)
		{
			cin >> A[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < N; ++i)
	{
		int ans_kari = 0;
		for (int j = 0; j < N; ++j)
		{
			if (i >= j)
			{
				ans_kari += A[0][j];
			}
			if (i <= j)
			{
				ans_kari += A[1][j];
			}
		}
		ans = max(ans, ans_kari);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  string S; cin >> S;
  int cnt1 = 0,cnt2 = 0;
  for (  int i  = 0; i < S.length(); i++ ) {
    if ( i % 2 == 0 ) {
      if ( S[i] == '0' ) cnt1++;
      else cnt2++;
    } else {
      if ( S[i] == '1' ) cnt1++;
      else cnt2++;
    }
  }
  cout << min(cnt1,cnt2) << endl;
  return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import math

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(math.sqrt(n))):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if __name__ == '__main__':
    # スペース区切りの整数の入力
    #N, K = map(int, input().split())
    # 文字列の入力
    N = int(input())
    #開業されたN個要素を受け付ける
    #input_list = [list(map(int, input().split())) for i in range(N)]
    factor = factorization(N)
    #print(factor)

    ans = 0
    if N == 1:
        ans = 0
    else:
        for f in factor:
            g = f[1]
            i = 1
            while(g>=i):
                ans = ans+1
                g=g-i
                i=i+1
    print(ans)


Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a>0)cout<<"Positive"<<endl;
  else if(a<=0&&0<=b)cout<<"Zero"<<endl;
  else{
    if((b-a+1)%2==0)cout<<"Positive"<<endl;
    else cout<<"Negative"<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
N, K = [int(i) for i in input().split(" ")]
n = [0 for _ in range(N)]

for i in range(K):
    num = int(input())
    D = [int(j) for j in input().split(" ")]
    for d in D:
        n[d-1] += 1

ans = 0
for i in n:
    if i == 0:
        ans += 1

print(ans)

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

typedef pair<int, int> Pii;

void readint(int N, vector<int> &a);
void readdouble(int N, vector<double> &a);
void readindex(int N, vector<int> &a);



signed main(){

    int N;
    cin >> N;
    vector<int> X(N), Y(N);
    readint(N, X);

    REP(i, N){
        Y[i] = X[i];
    }
    sort(Y.begin(), Y.end());

    int mid1 = Y[N / 2 - 1];
    int mid2 = Y[N / 2];

    REP(i, N){
        if(X[i] <= mid1){
            cout << mid2;
        }else{
            cout << mid1;
        }
        if(i != N - 1) cout << endl; 
    }
    
    return 0;
}








void readint(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readdouble(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str()) - 1;
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str()) - 1;
}

Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    long A=gl();
	    long V=gl();
	    long B=gl();
	    long W=gl();
	    long T=gl();
	    
	    long k=Math.abs(A-B);
	    long v=V-W;
	    long k2=v*T;
	    if (k>k2) {
	    	System.out.println("NO");
	    } else {
	    	System.out.println("YES");
	    }
	    //System.out.println(min);
	}

	// s進数で表した時の桁数
	public static int NsinKeta(int n, int s) {
		if(n==0) return 1;

		int i=0;
		while(n!=0) {
			n=Math.floorDiv(n, s);
			i++;
		}

		return i;
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35620
c=input()
a=int(c[:2])
b=int(c[2:])
if a in range(1, 13):
	if b in range(1, 13):
		s="AMBIGUOUS"
	else:
		s="MMYY"
elif b in range(1, 13):
	s="YYMM"
else:
	s="NA"
print(s)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 123456789012

int main(){
    ll i,j;
    ll n;
    
    VVI v(6060,VI(6060,0));
    string s,t;
    ll ans=0;
    cin>>s>>t;
    for(i=0;i<3;i++) if(s[i]==t[i]) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 144000
import java.util.*;

public class Main {        
    
  public static void main(String[] args) {              
     
      Scanner sc = new Scanner(System.in);                                    
    
      int N = sc.nextInt();
      int K = sc.nextInt();
                        
      int a[] = new int[N];
      
      for(int i = 0;i < N;i++){
          a[i] =  sc.nextInt();
      }
      
      Arrays.sort(a);
      
      int sum = 0;
      for(int i = N-K;i < N;i++){
          sum += a[i];
      }
      
      System.out.println(sum);            
     
  }     
}



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

#pragma region template


// -type-
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;


// -const-
const ll MOD = 1000000007;


const ll MAX = (ll)0x3f0000003f000000;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// -define-
#define F first
#define S second

#define reps(i, k, n) for (int i = (k), i##_len = (n); i < i##_len; ++i)
#define rep(i, n) reps(i, 0, n)
#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(x) cerr << x << " (L:" << __LINE__ << ")" << '\n';


// -functions-

inline bool in(string s, string c) {
    return (s.find(c) != string::npos);
}
inline bool in(string s, char c) {
    return (s.find(c) != string::npos);
}

template <class T>
void print(T& x) {
    cout << x << '\n';
}

struct setup_main {
    setup_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(15);
    }
} setup_main_;

#pragma endregion

ll ans = 0;

void solve(long long N) {
    cout << (int)pow(N, 3) << endl;
}
signed main() {
    long long N;
    scanf("%lld", &N);
    solve(N);

    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <list>

using namespace std;

#define TARO   0
#define HANAKO 1

int search(list<int>& target, int num) {
    list<int>::iterator it = target.begin();

    while (1) {
        if (it == target.end()) return 0;
        if (*it > num) {
            int ret = *it;
            target.erase(it);
            return ret;
        }
        it++;
    }
}

int main() {
    while (1) {
        int i;
        int n;
        vector<bool> flag(200);
        list<int> Taro;
        list<int> Hanako;
        int save;
        bool turn;

        scanf("%d", &n);
        if (n == 0) return 0;


        for (i=0;i<n;i++) {
            int k;

            scanf("%d", &k);
            Taro.push_back(k);
            flag[k-1] = 1;
        }

        for (i=0;i<2*n;i++) {
            if (!flag[i]) {
                Hanako.push_back(i+1);
            }
        }

        Taro.sort();
        Hanako.sort();

        list<int>::iterator it = Hanako.begin();

        turn = TARO;
        save = 0;
        while (1) {
            if (turn == TARO) {
                save = search(Taro, save);
                turn = HANAKO;
            } else {
                save = search(Hanako, save);
                turn = TARO;
            }

            if (Taro.empty() || Hanako.empty()) break;
        }

        printf("%d\n", Hanako.size());
        printf("%d\n", Taro.size());
    }
}

Measured memory_bytes: 1044
n = int(input())
value = input().split(" ")
a = [0] * n
    
for i in range(0, n):
    a[i] = int(value[i])

max = max(a)
min = min(a)
sum = 0

for i in range(0, n):
    sum = sum + a[i]


print("{0} {1} {2}".format(min, max , sum))


Measured memory_bytes: 6596
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;



void solve() {
  char c;
  cin >> c;
  if (c - 'a' < 0) cout << 'A' << endl;
  else cout << 'a' << endl;
}

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

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

int n,k,ans=0;
int a[200005];

signed main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++)  cin>>a[i];
	
	sort(a+1,a+n+1);
	
	for (int i=1;i<=k;i++)  ans+=a[i];
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    double a,b;
    cin >> a >> b;
    double c=b-a;
    cout << (c+1)*c/2-b << endl;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;


int main(){
  ll n;
  cin >> n;
  vvpll a(n);
  vrep(i, a){
    ll ai;
    cin >> ai;
    rep(j, 0, ai){
      ll x, y;
      cin >> x >> y;
      x--;
      i.push_back(make_pair(x, y));
    }
  }

  ll ans = 0;
  rep(bit, 0, 1<<n){
    bool check = true;
    rep(i, 0, n) if(bit>>i & 1) vrep(j, a.at(i)){
      if(j.second == 0 && (1<<j.first & bit)) check = false;
      if(j.second == 1 && !(1<<j.first & bit)) check = false;
    }
    if(check){
      ll tr = 0;
      rep(j, 0, n)if((1<<j) & bit) tr++;
      chmax(ans, tr);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

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

		// 入力
		int n = sc.nextInt();//
		int[] l = new int[n]; 
		for(int i = 0; i < n; i++){
			l[i] = sc.nextInt();
		}

		int maxL = 0;
		int theL = -1;
		for(int i = 0; i < n; i++){
			if(maxL < l[i]){
				maxL = l[i];
				theL = i;
			}
		}

		int sum = 0;
		for(int i = 0; i < n; i++){
			if(theL != i){
				sum = sum + l[i];
			}
		}		

		String result = "No";
		if(maxL < sum) result = "Yes";

		// 出力
		System.out.println(result);
	}

}




Measured memory_bytes: 23764
#include <iostream>
using namespace std;
#define L long long
int main()
{
    L a,b,c;
    cin >> a >> b >> c;
    L a1 = (a%c == 0?a/c:a/c+1);
    L a2 = b/c;
    cout << a2-a1+1;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		
		int ans = 0;
		for(int i = 1;i <= N;++i)
			ans += i;
		System.out.println(ans);
	}
}


Measured memory_bytes: 23636
import java.util.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                String s = sc.next();
                int[] a = new int[3];
                Arrays.fill(a , 0);
                for(int i = 0 ; i < 3 ; i++){
                        if(s.charAt(i) == 'R') a[i] = 1;
                }
                if(a[0] == 1 && a[1] == 1 && a[2] == 1){
                        System.out.println(3);
                }else if(a[0] == 1 && a[1] == 1){
                        System.out.println(2);
                }else if(a[1] == 1 && a[2] == 1){
                        System.out.println(2);
                }else if(a[0] == 0 && a[1] == 0 && a[2] == 0){
                        System.out.println(0);
                }else{
                        System.out.println(1);
                }
        }
}

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


Measured memory_bytes: 128
#include <iostream>
    #include <string>
    #include <vector>
    #include <algorithm>
    #include <cmath>
    #include <cstdio>
    #include <functional>
    #include <numeric>
    #include <stack>
    #include <queue>
    #include <map>
    #include <set>
    #include <utility>
    #include <sstream>
    #include <complex>
    #include <fstream>
    #include <bitset>
    #include <time.h>
    #include <tuple>
     
    using namespace std;
     
    typedef long long ll;
    typedef pair<ll, ll> P;
    typedef vector<ll> V;
    typedef complex<double> Point;
     
    #define PI acos(-1.0)
    #define EPS 1e-10
    const ll INF = (1LL << 60) - 1;
    const ll MOD = 1e9 + 7;
     
    #define FOR(i,a,b) for(int i=(a);i<(b);i++)
    #define rep(i,N) for(int i=0;i<(N);i++)
    #define ALL(s) (s).begin(),(s).end()
    #define EQ(a,b) (abs((a)-(b))<EPS)
    #define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
    #define fi first
    #define se second
    #define N_SIZE (1LL << 20)
    #define NIL -1
    #define MAX_N 100100 * 3
     
    int x, t;
     
    int main() {
    	cin >> x >> t;
    	cout << max(0, x - t) << endl;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c = 0;
    cin>>n;
    int arr[n],brr[n];
    for(int i = 0; i<n;i++)
    {
        cin>>arr[i];
        brr[i] = arr[i];
    }
    sort(brr,brr+n);
    for(int i = 0;i<n;i++)
    {
        if(brr[i] != arr[i])
        {
            c++;
        }
    }
    if(c <= 2)
        cout<< "YES"<<endl;
    else
        cout<< "NO" <<endl;

}


Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
As = [list(map(int, input().split())) for _ in range(N)]
num = 0
for A in As:
    s = sum([a * b for a, b in zip(A, B)]) + C
    if s > 0:
        num += 1
print(num)


Measured memory_bytes: 3060
import itertools


def main():
    N = int(input())
    F = [tuple(map(int, input().split())) for _ in range(N)]
    P = [tuple(map(int, input().split())) for _ in range(N)]
    ans = -float("inf")
    for ptn in itertools.product((0, 1), repeat=10):
        if ptn == (0, 0, 0, 0, 0, 0, 0, 0, 0, 0):
            continue
        tmp = 0
        for i in range(N):
            common = sum([ptn[x] * F[i][x] for x in range(10)])
            tmp += P[i][common]
        ans = max(tmp, ans)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 42588
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "abc163_c.cpp"

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  map<int, int> mp;
  REP(i, n - 1) {
    int a;
    cin >> a;
    a--;
    mp[a]++;
  }
  REP(i, n) { cout << mp[i] << endl; }
}


Measured memory_bytes: 12988
#include <stdio.h>

void solve(int a, int b) {
    int a_tmp = a, b_tmp = b, i, sum, max = 0;
    for(i = 0; i < 1<<2; ++i) {
        a_tmp = a; b_tmp = b; sum = 0;
        if((i & 1) == 0) { sum += a_tmp; --a_tmp; }
        else { sum += b_tmp; --b_tmp; }

        if((i & 2) == 0) { sum += a_tmp; --a_tmp; }
        else { sum += b_tmp; --b_tmp; }
        max = (max < sum) ? sum : max;
    }
    printf("%d\n", max);
}

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    solve(a,b);
    return 0;
}

Measured memory_bytes: 128
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let n: usize = buf.trim_right().parse().unwrap();

    struct Lucas {
        curr: u64,
        next: u64,
    }
    impl Iterator for Lucas {
        type Item = u64;
        fn next(&mut self) -> Option<u64> {
            let new_next = self.curr + self.next;

            self.curr = self.next;
            self.next = new_next;

            // Since there's no endpoint to a Lucas sequence, the `Iterator`
            // will never return `None`, and `Some` is always returned.
            Some(self.curr)
        }
    }
    fn lucas() -> Lucas { Lucas { curr: 2, next: 1 } }
    writeln!(output, "{}", lucas().nth(n - 1).unwrap()).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "5
",
            "11\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "86
",
            "939587134549734843\n",
        );
    }
}


Measured memory_bytes: 4352
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with(false); cin.tie(0);cout.tie(0);
const int MOD = 1000000007;
#define PI = acos(-1)
using namespace std ;
int a[106];
int main(){
    int n ; cin >> n ;
    map<int,int>mp;
    vector<int> v(n);
    for(int i  =0 ; i<n ; i++){
    	 cin >> v[i];
    	 mp[v[i] - 1]++;
    	 mp[v[i]+1]++;
    	 mp[v[i]]++;
	}
	int maxx = 0 ;
	for(auto x:mp){
		maxx = max(maxx , x.second);
	}
	cout << maxx << endl;
}



Measured memory_bytes: 7856
import java.io.*;
import java.util.*;

public class Main {
    private static class Solver {
        private void Solve() {
            int n = inp.nextInt();
            int k = inp.nextInt();

            long[] c = new long[k];
            for (int i = 0; i < k; ++i) {
                c[i] = 0;
            }
            for (int i = 1; i <= n; ++i) {
                c[i % k] += 1;
            }

            long ans = 0;
            long cnt = c[0];
            ans = ans + cnt * cnt * cnt;
            if (k % 2 == 0) {
                cnt = c[k / 2];
                ans = ans + cnt * cnt * cnt;
            }
            out.println(ans);
        }

        static InputReader inp;
        static PrintWriter out;
    }

    private static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        private InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        private String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

    }

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Solver.inp = new InputReader(inputStream);
        Solver.out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.Solve();
        Solver.out.close();
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
const int N=100;
const int W=10000;
int n,w;

struct nap{
    vector<ll> v,w;
    ll N,W;
    vector< vector<ll> > dp;
    nap(ll n,ll wmax){
        N=n;W=wmax;
        v.resize(n);
        w.resize(n);
        vector<ll> wv(W+1,0);
        FOR(i,0,n+1){
            dp.push_back(wv);
        }
    }
    void calc(){
        FOR(i,0,N){
            FOR(j,0,W+1){
                if(j<w[i]){
                    dp[i+1][j]=dp[i][j];
                }else{
                    dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
                }
            }
        }
    }
    ll maxval(ll w){
        return dp[N][w];
    }
 
 
};
 
 
int main(){
    cin>>n>>w;
    nap na(n,w);
    FOR(i,0,n){
        cin>>na.w[i]>>na.v[i];
    }
    na.calc();
    cout<<na.maxval(w)<<endl;
    return 0;
}

Measured memory_bytes: 80256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


signed main(void) {
    int n,m;
    cin >> n >> m;
    vi p(m+1);
    vp y(m);
    rep(i,m){
        cin >> p[i] >> y[i].first;
        y[i].second = i;
    }
    sort(all(y));
    vi ans(m),a(n+1);
    rep(i,m){
        int ind = y[i].second;
        int q = p[ind];
        a[q]++;
        ans[ind] = a[q];
    }
    rep(i,m){
        string s = to_string(p[i]);
        while(s.size() < 6)s = "0" + s;
        cout << s;
        s = to_string(ans[i]);
        while(s.size() < 6)s = "0" + s;
        cout << s << endl;
    }
}


Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <numeric>
#define rep(i,n) for(int i=0;i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;
int main(){
        int n,k;
        cin >> n >> k;
        int ans = 1;
        while(n){
                if(ans < k){
                        ans *= 2;
                }else ans += k;
                n--;
        }
        cout << ans << endl;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	char a, b; scanf(" %c %c", &a, &b);
	if (a == 'H') {
		printf("%c", b);
	} else {
		if (b == 'H') puts("D");
		else puts("H");
	}
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
def main():
    N, A, B, C = map(int, input().split())
    len_banboo = []
    for i in range(N):
        len_banboo.append(int(input()))

    list_mp = []
    for i in range(4 ** N):
        materials = [0] * N
        tmp = i
        zero_cnt = 0

        for j in range(N):
            materials[(N-1)-j] = tmp % 4
            tmp //= 4
            if materials[(N-1)-j] == 0:
                zero_cnt += 1

        if (1 in materials and 2 in materials and 3 in materials) == False:
            continue

        a_mat, b_mat, c_mat = 0, 0, 0
        cost_mp = 0
        for k in range(len(len_banboo)):
            if materials[k] == 0:
                continue
            elif materials[k] == 1:
                if a_mat > 0:
                    cost_mp += 10
                a_mat += len_banboo[k]
            elif materials[k] == 2:
                if b_mat > 0:
                    cost_mp += 10
                b_mat += len_banboo[k]
            elif materials[k] == 3:
                if c_mat > 0:
                    cost_mp += 10
                c_mat += len_banboo[k]

        cost_mp += (abs(A - a_mat) + abs(B - b_mat) + abs(C - c_mat))
        list_mp.append(cost_mp)

    print(min(list_mp))


if __name__ == "__main__":
    main()

Measured memory_bytes: 4996
position,moves,distance=[int(x) for x in input().split()]
position=abs(position)
if position>=distance*moves:
	print(abs(position-distance*moves))
else:
	variable=moves-position//distance
	if variable%2==0:
		print(abs((position-distance*(position//distance))))
	else:
		print(abs(position-distance*((position//distance) + 1)))

Measured memory_bytes: 61908
#include <iostream>
using namespace std;
int main() {
    int a,b,c,d;
    cin>>a>>b>>c;//c,a,bの順になればいい
    d = a;
    a = c;
    c = b;
    b = d;
    cout<<a<<" "<<b<<" "<<c<<""<<endl;
    
    return 0;
}


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 500010, M = 26;

int n, m;
char s[N];
set<int> S[M];

int check(int i, int l, int r)
{
	auto it = S[i].lower_bound(l);
	if (it == S[i].end() || *it > r) return 0;
	else return 1;
}

int main()
{
	scanf("%d%s%d", &n, s + 1, &m);
	for (int i = 1; i <= n; i ++ ) S[s[i] - 'a'].insert(i);
	
	while (m -- )
	{
		int t;
		scanf("%d", &t);
		if (t == 1)
		{
			int i;
			char c[3];
			scanf("%d%s", &i, c);
			
			S[s[i] - 'a'].erase(i);
			S[c[0] - 'a'].insert(i);
			s[i] = c[0];
		}
		else
		{
			int l, r, res = 0;
			scanf("%d%d", &l, &r);

			for (int i = 0; i < M; i ++ ) res += check(i, l, r);
			printf("%d\n", res);
		}
	}
	return 0;
}

Measured memory_bytes: 24192
import sys,bisect,math
input = sys.stdin.readline

N,C,K = list(map(int,input().split()))
T = sorted([int(input()) for i in range(N)])

n = 0
cnt = 0
while n < N:
    target = T[n]+K
    nb = n
    n = bisect.bisect_right(T,target)
    if n - nb > C:
        n = nb + C
    cnt += 1
print(cnt)


Measured memory_bytes: 14000
n, m = map(int, input().split())
c = list(map(int, input().split()))
INF = float("inf")

dp = [INF]*(n+1)
dp[0] = 0

for i in range(m):
    for j in range(n+1):
        if j + c[i] > n:
            break
        else:
            dp[j + c[i]] = min(dp[j + c[i]], dp[j] + 1)

print(dp[n])


Measured memory_bytes: 7532
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long 
#define ll long long 
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair 
#define INF 1000000000
#define MOD 1000000007 
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint()
{
	int x=0,p=1;char c;
	c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;
//
const int maxn=1e5+5;
ll a[maxn],pre[maxn];
int n;
//
int main()
{
	n=getint();
	a[0]=0;
	pre[0]=0;
	for(int i=1;i<=n;i++)
	{
		int x=getint();
		a[i]=x;
		pre[i]=pre[i-1]+1ll*abs(a[i]-a[i-1]);
	}
	a[n+1]=0;
	pre[n+1]=pre[n]+1ll*abs(a[n+1]-a[n]);
	for(int i=1;i<=n;i++)
	{
		ll res=pre[i-1]+pre[n+1]-pre[i+1]+abs(1ll*a[i+1]-a[i-1]);
		cout<<res<<endl;
	}
	return 0;	
} 

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

using namespace std;

int main()
{
    int n, max = INT_MIN, sum = 0, l;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &l);
        if (l > max)
            max = l;
        sum += l;
    }

    printf("%s\n", max < sum - max ? "Yes" : "No");

    return 0;
}


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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
  return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#pragma warning(disable:4996)
#define max 100005
int main()
{
	int a[max], i, j, n, p = 0, sum=0,x,y;
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		if (a[i] == 2)p = i;
	}
	if (p == 0) { printf("-1"); return 0; }
	x = 1; y = a[x];
	while (y!=2)
	{
		y = a[y];
		sum++;
		if(sum>n-1) { printf("-1"); return 0; }
	}
	sum++;
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<stack>
typedef unsigned int uint;
using namespace std;

inline bool opp(char c1,char c2){
  return (c1==')' && c2 == ']') || (c1==']' && c2==')');
}

bool check(string str){
  stack<uint> Stack;
  uint pos=0;
  for(;pos<str.size();pos++){
    if(str[pos]==')' || str[pos]==']') return false;
    if(str[pos]=='('){
      Stack.push(')');
      break;
    }else if(str[pos]=='['){
      Stack.push(']');
      break;
    }
  }
  
  for(pos++;pos<str.size();pos++){
    if(str[pos]=='('){
      Stack.push(')');
    }else if(str[pos]=='['){
      Stack.push(']');
    }
    else if(!Stack.empty()){
      char c=Stack.top();
      if(opp(str[pos],c)){
	return false;
      }else if(str[pos]==c){
	Stack.pop();
      }
    }else if(Stack.empty() && (str[pos]==')' ||str[pos]==']')){
      return false;
    }
  }
  if(Stack.empty())
    return true;  
  else 
    return false;
}

int main(){
  string str;
  while(getline(cin,str),str!="."){
    if(check(str))
      cout<<"yes"<<endl;
    else
      cout<<"no"<<endl;

  }
  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

int main() {
  string s;
  cin >> s;
  string ans = "Good";
  rep(i, s.size() - 1) {
    if (s[i] == s[i + 1]) ans = "Bad";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*
▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄██████████████▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
*/
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <iomanip>
#include <random>


using namespace std;

#define ll long long
#define ld long double
#define null NULL
#define prev prev228
#define next next228
#define index index228
#define count count228





signed main() {
	int n;
	scanf("%d", &n);
	map<int, int> cnt;
	for (int i = 1; i <= n; ++i) {
		int a;
		scanf("%d", &a);
		++cnt[a];
		++cnt[a + 1];
		++cnt[a - 1];
	}
	int res = 0;
	for (auto p : cnt) {
		res = max(res, p.second);
	}
	printf("%d\n", res);
	return 0;
}












Measured memory_bytes: 4736
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;
}

Measured memory_bytes: 3616