akhauriyash/Code-Regression huggingface dataset:
def solve() :
    n = map(int, input().split()) 
    a = list(map(int, input().split()))

    total = 1

    if 0 in a :
        print(0)
        return

    for i in a :
        total *= i

        if total > 10 ** 18 :
            print(-1)
            return

    print(total)

if __name__ == "__main__" :
    solve()

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

int main()
{
    int R;
    cin >> R;

    if( R<1200){
        cout << "ABC" << endl;
    }else if( R < 2800 ){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_e

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1e9 + 7)
#define LINF (1e18)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

// dp[i] : 重さi以下の価値を最大化する
ll dp[100001];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, w, i1, i2;
    cin >> n >> w;
    REP(i, n) {
        cin >> i1 >> i2;
        for (ll k = w; k >= i1; k--) {
            dp[k] = max(dp[k], dp[k - i1] + i2);
        }
    }
    cout << dp[w] << endl;

    return 0;
}


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

void solve() 
{
    string s;cin>>s;
    if (s[s.size()-1]=='s')cout<<s+"es"<<endl;
    else cout<<s+"s"<<endl;
}

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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
inline void solve(){
	int w,h;cin>>w>>h;
	int dp[w][h];
	for(int i=0;i<w;i++)for(int j=0;j<h;j++){
		char c;cin>>c;
		if(c=='.')dp[i][j]=0;
		else if(c=='#') dp[i][j]=-1;
	}
	dp[0][0]=1;
	/*for(int i=0;i<w;i++){
		for(int j=0;j<h;j++)cout<<dp[i][j];
		cout<<endl;
	}*/
	for(int i=0;i<w;i++){
		for(int j=0;j<h;j++){
			if(dp[i][j]!=(-1)){
				if(i!=0&&dp[i-1][j]!=(-1))dp[i][j]+=dp[i-1][j];
				if(j!=0&&dp[i][j-1]!=(-1))dp[i][j]+=dp[i][j-1];
				dp[i][j]%=1000000007;
				//dp[i][j]+=dp[i-1][j]+dp[i][j-1];
			}
		}
	}/*
	for(int i=0;i<w;i++){
		for(int j=0;j<h;j++)cout<<dp[i][j];
		cout<<endl;
	}*/
	cout<<(dp[w-1][h-1]%1000000007);
	return;
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	solve();
	return 0;
}

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

int main(){
	// sengen
	string s;
	// nyuryoku
	cin >> s;
	// keisan
	int a = (s[0] - '0')*10 + (s[1] - '0');
	int b = (s[2] - '0')*10 + (s[3] - '0');
	if(a*b == 0){
		if(a > 12 || b > 12){
			cout << "NA" << endl;
		}else if(a > b){
			cout << "MMYY" << endl;
		}else if(b > a){
			cout << "YYMM" << endl;
		}else{
			cout << "NA" << endl;
		}
	}else if(a <13 && b <13){
		cout << "AMBIGUOUS" << endl;
	}else if(a > 12 && b > 12){
		cout << "NA" << endl;
	}else if(a < 13){
		cout << "MMYY" << endl;
	}else{
		cout << "YYMM" << endl;
	}
	// syutsuryoku
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define M 100007
#define mod 1000000007
using namespace std;
int n,k,dp[M],ans=1;
vector<int>q[M];
void dfs(int x,int f,int p) {
	ans=1ll*ans*p%mod;
	int w=0;
	if(!f)w=1;
	else w=2;
	for(int i=0; i<(int)q[x].size(); i++) {
		if(q[x][i]!=f) {
			if(w>k) {
				ans=0;
				return;
			}
			dfs(q[x][i],x,k-w);
			w++;
		}
	}
}
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1,a,b; i<n; i++) {
		scanf("%d%d",&a,&b);
		q[a].push_back(b);
		q[b].push_back(a);
	}
	dfs(1,0,k);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

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

vector<pair<int,int>> tonari[410]; //(next node,dist)
int dist[410][410],to[410][410];
int tmax;

class Order{
public:
    int dst,ot; //目的地と注文時刻 destination ordertime
    bool arrive=false;

    Order(int x,int y){
        dst=y;
        ot=x;
    }
    
    Order(const Order& src){ //コピーコンストラクタ
        dst=src.dst;
        ot=src.ot;
    }
};

vector<int> path(int s, int g){
    vector<int> tmp;
    int pos;
    for (pos = s; pos!=g ; pos=to[pos][g]) {
        tmp.push_back(pos);
    }
    tmp.push_back(g);
    return tmp;
}

int go(int start,int goal,int starttime){ //到着時の時刻を返す
    vector<int> pathtod(path(start,goal));
    //for(int a:pathtod) cout<<a<<" ";
    //cout<<endl<<dist[0][1]<<endl;
    int pos=start,i=1;
    while(pos!=goal&&starttime<tmax){
        //cout<<"syoyo:"<<dist[pos][pathtod[i]]<<endl;
        int tmp=tmax-starttime;
        for (int j = 0; j < min(dist[pos][pathtod[i]], tmp); ++j) {
            //cout<<start<<","<<starttime<<":";
            cout<<pathtod[i]+1<<endl;
            ++starttime;
        }
        pos=pathtod[i];
        ++i;
        //cout<<pos<<endl;
    }
    //cout<<"OK"<<endl;
    return starttime;
}

int main() {
    int N,M; cin>>N>>M;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            to[i][j]=j;
            if(i==j) dist[i][j]=0;
            else dist[i][j]=MOD; //初期化
        }
    }
    int u,v,d;
    for (int i = 0; i < M; ++i) {
        cin>>u>>v>>d; --u; --v;
        tonari[u].push_back(make_pair(v,d));
        tonari[v].push_back(make_pair(u,d));
        dist[u][v]=d;
        dist[v][u]=d;
    }

    //ワーシャルフロイド
    for (int k = 0; k < N; ++k) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                if(chmin(dist[i][j],dist[i][k]+dist[k][j])){
                    to[i][j]=to[i][k];
                }
            }
        }
    }

    cin>>tmax;
    //注文情報を受け取る
    int Ncnt,id,dst;
    vector<Order> od;
    for (int i = 0; i < tmax; ++i) {
        cin>>Ncnt;
        if(Ncnt){
            cin>>id>>dst; --dst;
            od.push_back(Order(i,dst));
        }
    }

    for(auto a:od){
        //cout<<a.ot<<" "<<a.dst<<endl;
    }
    
    //まずは注文順で毎回店に戻る
    int prenode=0,dstnode=0;
    int update=0; //最後にノード0に来た時刻
    int i=0,t=0;
    vector<int> nextpath;

    while(t<tmax){
        if(t<od[0].ot||(prenode==0&&t<od[i].ot)||i>=od.size()) {
            cout<<-1<<endl;
            ++t;
            continue; //最初の注文までは動かない
        }

        if(prenode==0){
            dstnode=od[i].dst;
            t=go(prenode,dstnode,t);
            prenode=dstnode;
            ++i;
        }else{
            dstnode=0;
            t=go(prenode,dstnode,t);
            prenode=0;
        }
    }


    return 0;
}

Measured memory_bytes: 1792
S=input()
ans=0
a=0
for i in range(len(S)):
    if S[i]=="A":
        if i>0 and S[i-1]=="B":
            a=0
        a+=1
    elif S[i]=="B":
        if i>0 and S[i-1]=="B":
            a=0
    elif S[i]=="C":
        if i>0 and S[i-1]=="B":
            ans+=a
        else:
            a=0
print(ans)

Measured memory_bytes: 3500
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>

#define rep( i, m, n ) for(int( i ) = ( m ); ( i ) < ( n ); ( i )++)

int main( void ){
	int  n;
	if (!scanf( "%d", &n ))
		return -1;
	double rev_sum = 0.0;
	double input;
	rep(i,0,n){
		if (!scanf( "%lf", &input ))
			return -1;
		rev_sum += 1/input;
	}
	printf("%lf\n", 1/rev_sum);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
 
#define mod 1000000007
long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int h, n; cin>>h>>n;
	int a[n], b[n];
	int dp[h+1] = {};
	for(int i = 0; i < n; i++){
		cin>>a[i]>>b[i];
	}
	for(int i = 0; i < n; i++){
		for(int u = 1; u < h+1; u++){
			if(i == 0){
				dp[u] = (u > a[i] ? dp[u-a[i]] + b[i] : b[i]);
			}else{
				dp[u] = min((u > a[i] ? dp[u-a[i]] + b[i] : b[i]), dp[u]);
			}
		}
	}
	cout<<dp[h];
	return 0;
}


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

lli min(lli a,lli b)
{
    if(a<b)
    {
        return a;
    }
    return b;

}
lli n,m;

int main()
{
    cin>>n>>m;
    lli ans=n*(n-1)/2;
    ans+=m*(m-1)/2;
    cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int N,i,j,k,x;
  int A[100];
  
  scanf("%d",&N);
  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
  }
  
  x=0;
 for(i=0;i<N;i++){
   for(j=N-1; i<j; j--){
     k = A[j];
     if(A[j] < A[j-1]){
       A[j]=A[j-1];
       A[j-1]=k;
       x++;
     }
   }
 }
 
 for(i=0;i<N;i++){
   if(i != 0)
     {
       printf(" ");
     }
   printf("%d",A[i]);
 }
 printf("\n");
 printf("%d\n",x);
 return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static boolean solve() {
		int a = in.nextInt();
		int l = in.nextInt();
		if (a + l == 0) return false;

		HashMap<Integer,Integer> map = new HashMap<>();
		int p = 0;
		while (true) {
			if (map.containsKey(a)) {
				break;
			}
			map.put(a, p);

			ArrayList<Integer> max = new ArrayList<>();
			ArrayList<Integer> min = new ArrayList<>();

			while (a != 0) {
				max.add(a%10);
				min.add(a%10);
				a /= 10;
			}

			while (max.size() < l) {
				max.add(0);
				min.add(0);
			}

			Collections.sort(max);
			Collections.sort(min, new Comparator<Integer>(){
				public int compare(Integer a, Integer b) {
					return b - a;
				}
			});

			int maxI = 0, minI = 0, d = 1;
			for (int i=0; i<l; i++) {
				maxI += max.get(i)*d;
				minI += min.get(i)*d;
				d *= 10;
			}

			a = maxI - minI;
			p++;
		}

		out.println(map.get(a)+" "+a+" "+(p-map.get(a)));

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 27224
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    int a, b;
    cin >> a >> b;
    if(a * b <= 0) cout << "Zero" << endl;
    else if(a > 0 || (b - a) % 2) cout << "Positive" << endl;
    else cout << "Negative" << endl;
}

Measured memory_bytes: 256
# http://www.geocities.jp/m_hiroi/light/pyalgo61.html

class UnionFind3:
    def __init__(self, size):
        # 負の値はルート (集合の代表) で集合の個数
        # 正の値は次の要素を表す
        self.table = [-1 for _ in range(size)]

    # 集合の代表を求める
    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            # 経路の圧縮
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    # 併合
    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                # 小さいほうが個数が多い
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False


N, M = [int(i) for i in input().split()]
p = [int(i) - 1 for i in input().split()]

uf = UnionFind3(N + 1)
for i in range(M):
    x, y = [int(i)-1 for i in input().split()]
    uf.union(x, y)

count = 0
for i in range(N):
    if p[i] != i:
        if uf.find(p[i]) == uf.find(i):
            count += 1
            # pi = p[i]
            # ppi = p[pi]
            # p[i], p[pi] = ppi, pi
    else:
        count += 1
print(count)

Measured memory_bytes: 13812
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
template <bool Directed, typename TEdge, bool Index> struct graph {
    using EType = TEdge;
    vector<TEdge> edges;
    vector<vector<int>> adj;
    graph(int n) : adj(n + Index) {}
    graph(int n, int m) : graph(n) { edges.reserve(m << not Directed); }
    TEdge& operator()(int e) { return edges[e]; }
    vector<int>& operator[](int u) { return adj[u]; }
    int size() { return adj.size() - Index; }
    void append(int u, const TEdge& e) {
        adj[u].push_back(edges.size());
        edges.push_back(e);
    }
    void add_edge(const TEdge& e) {
        append(e.u, e);
        if(not Directed) append(e.v, e.reverse());
    }
};
template <typename T> using f = function<T>;
template <typename TEdge> struct dfs_params {
    f<void(int)> pre_node = [](int) -> void {};
    f<void(int)> pos_node = [](int) -> void {};
    f<void(TEdge&)> pre_edge = [](TEdge&) -> void {};
    f<void(TEdge&)> pos_edge = [](TEdge&) -> void {};
    int root = 0;
};
template <bool Directed, typename TEdge, bool Index, typename TParamsetter = f<void(dfs_params<TEdge>&)>>
vector<int> dfs(graph<Directed, TEdge, Index>& g, const TParamsetter& psetter = [](dfs_params<TEdge>&) {}) {
    static_assert(is_convertible<decltype(psetter), f<void(dfs_params<TEdge>&)>>::value, "psetter must be void(dfs_params<TEdge>&)");
    dfs_params<TEdge> params;
    psetter(params);
    vector<int> component(g.adj.size());
    function<void(int, int)> dfs = [&](int u, int c) {
        component[u] = c;
        params.pre_node(u);
        for(int e : g[u]) if(not component[g(e).v]) {
            params.pre_edge(g(e)), dfs(g(e).v, c), params.pos_edge(g(e));
        }
        params.pos_node(u);
    };
    if(params.root) {
        dfs(params.root, 1);
    } else {
        for(int u = Index, c = 0; u < g.adj.size(); u++) if(not component[u]) {
            dfs(u, ++c);
        }
    }
    return component;
}
struct edge {
    int u, v;
    edge reverse() const { return {v, u}; }
    friend ostream& operator<<(ostream& os, const edge& e) {
        return os << "{u: " << e.u << ", v: " << e.v << "}";
    }
};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    graph<0, edge, 1> g(n, n - 1);
    for(int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        g.add_edge({u, v});
    }
    ll ans = n;
    dfs(g, [&](auto& p) {
        p.pos_edge = [&](edge& e) {
            auto [p, v] = e;
            if(v < p) {
                ans += ll(p - v) * v;
            } else {
                ans += ll(v - p) * (n - v + 1);
            }
        };
    });
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int flg = 0;
  for (int i = 1; i < 10; i++) {
    if (i > N) {
      continue;
    }
    int j = N / i;
    int m = N % i;
    if (1 <= j && j <= 9 && m == 0) {
      cout << "Yes" << endl;
      flg = 1;
      break;
    }
  }
  if (flg == 0) {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
ll x;
int main(){
  ll ans = 0;
  cin>>x;

  ans = x/11;

  
  if(x % 11 == 0){
    cout<<ans*2<<endl;
  }
  
  else if(x % 11 < 7){
    cout<<ans*2+1<<endl;
  }
  else {cout<<ans*2+2<<endl;}

 
}


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

using namespace std;
const int mod = 1000000007;
int a[2000], fct[2000];
int f[201][100001];
int main() {
	ios_base::sync_with_stdio(false);
	int n, x;
	cin >> n >> x;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	f[n][x] = 1;
	for (int i = n; i >= 1; i--) {
		for (int j = x; j >= 0; j--) {
			if (f[i][j] == 0) {
				continue;
			}
			f[i - 1][j % a[i]] += f[i][j];
			if (f[i - 1][j % a[i]] >= mod) {
				f[i - 1][j % a[i]] -= mod;
			}
			f[i - 1][j] += 1ll * f[i][j] * (i - 1) % mod;
			
			if (f[i - 1][j] >= mod) {
				f[i - 1][j] -= mod;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < a[1]; i++) {
		ans += 1ll * i * f[0][i] % mod;
		if (ans >= mod) {
			ans -= mod;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 76928
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define LL long long
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define fd(i,j,k) for(int i=j;i>=k;i--)
#define fr(i,j) for(int i=beg[j];i;i=nex[i])
using namespace std;
int const mn=100+3,ma=1e7;
int n,a[mn],tag[ma],ss[ma],b[2][mn],
	gra,beg[mn],to[mn*mn],nex[mn*mn],vis[mn],re[mn];
void ins(int u,int v){
	to[++gra]=v;
	nex[gra]=beg[u];
	beg[u]=gra;
}
int dfs(int p){
	vis[p]=1;
	fr(i,p)if((!re[to[i]])||((!vis[re[to[i]]])&&dfs(re[to[i]]))){
		re[to[i]]=p;
		return 1;
	}
	return 0;
}
int main(){
	scanf("%d",&n);
	fo(i,1,n)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	b[a[1]&1][++b[a[1]&1][0]]=a[1];
	b[(a[n]+1)&1][++b[(a[n]+1)&1][0]]=a[n]+1;
	fo(i,2,n)if(a[i-1]+1!=a[i])
		b[(a[i-1]+1)&1][++b[(a[i-1]+1)&1][0]]=a[i-1]+1,
		b[a[i]&1][++b[a[i]&1][0]]=a[i];
	tag[1]=1;
	fo(i,2,ma){
		if(!tag[i])ss[++ss[0]]=i;
		fo(j,1,ss[0]){
			if(1ll*i*ss[j]>ma)break;
			tag[i*ss[j]]=1;
			if(!(i%ss[j]))break;
		}
	}
	fo(i,1,b[0][0])fo(j,1,b[1][0])
		if(!tag[abs(b[0][i]-b[1][j])])ins(i,j);
	int tmp=0;
	fo(i,1,b[0][0]){
		memset(vis,0,sizeof(vis));
		tmp+=dfs(i);
	}
	printf("%d",tmp+2*((b[0][0]-tmp)/2+(b[1][0]-tmp)/2)+3*((b[0][0]-tmp)&1));
	return 0;
}


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

int main() {
    int n, k, ans = 1;
    cin >> n >> k;
    rep(i, n) {
        if(ans * 2 <= ans + k) {
            ans = ans * 2;
        }
        else {
            ans = ans + k;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int N;
  cin >> N;
  if(N == 1){
    cout << "Hello World" << endl;
  }else{
    int A, B;
    cin >> A >> B;
    int ans = A + B;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<ll,l_l> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ll n,m,s,t;
vl path[100100];
ll dp[100010][4];

void Dijkstra(){
    rep(i,n){
        rep(j,4){
            dp[i][j]=LINF;
        }
    }
    dp[s][0]=0;
    priority_queue<lll,vector<lll>,greater<lll>> pq;
    pq.push({0,{s,0}});
    while(pq.size()){
        auto it=pq.top();pq.pop();
        ll nowpos=it.se.fi;
        ll nowcost=it.fi;
        ll nowt=it.se.se;
        for(auto nxtpos:path[nowpos]){
            ll nxtcost=nowcost+((nowt+1)%3==0?1:0);
            if(chmin(dp[nxtpos][(nowt+1)%3],nxtcost)){
                pq.push({nxtcost,{nxtpos,(nowt+1)%3}});
            }
        }
    }
}
int main(){
    cin>>n>>m;
    rep(i,m){
        ll u,v;cin>>u>>v;
        u--;v--;
        path[u].pb(v);
    }
    cin>>s>>t;
    s--;t--;
    Dijkstra();
    if(dp[t][0]==LINF)cout<<-1<<endl;
    else cout<<dp[t][0]<<endl;
    return 0;
}

Measured memory_bytes: 11248
package main

import (
	"fmt"
)

func main() {
	// 5 3
	// 1 2 2 4 5
	var k, n int

	fmt.Scanf("%d %d\n", &k, &n)
	dp := make([]float64, k)
	p := make([]float64, k)
	for i := 0; i < k; i ++ {
		var v int
		fmt.Scanf("%d", &v)
      a := 0.5 * float64(v) + 0.5
		dp[i] = a
		p[i] = a
		if i > 0 {
			dp[i] += dp[i-1]
		}
		if i >= n {
			dp[i] -= p[i-n]
		}
	}
	max := 0.0
	for _, sum := range dp {
		if sum > max {
			max = sum
		}
	}
	
	fmt.Printf("%f", max)
	
}

Measured memory_bytes: 7808
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int x, n;
	cin >> x >> n;
	
	vector<int> p(n);
	map<int, int> mp;
	for(int i = 0; i < n; ++i) {
		cin >> p[i];
		mp[p[i]]++;
	}
	
	if( n == 0 ) {
		cout << x << endl;
		return 0;
	}
	
	int dis = 200;
	vector<int> res;
	for(int i = -10000; i <= 10000; ++i) {
		if( mp[i] > 0 ) continue;
		
		if( dis > abs(x - i) ) {
			dis = abs(x - i);
			res.push_back(i);
		}
	}
	
	int d = 200;
	int ans = 0;
	for(auto& v : res) {
		if( d >= abs(x - v) ) {
			d = abs(x - v);
			ans = v;
		}
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4536
main :: IO ()
main = readLn >>= putStrLn.unwords.map show.solve

lim :: Int
lim = 30000

solve :: Int -> [Int]
solve 3 = [2, 3, 25]
solve n
  | even n = take n xs
  | otherwise = (lim:).take(n-1) $ xs
  where
    xs = [2,3,4,9] ++ concat[[6*k+2, 6*k+4]|k<-[1..div lim 6 - 1]] ++ [15,21..lim] ++ [6,12..lim]


Measured memory_bytes: 1532
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int main(){
    int x; cin >> x;

    if(x) cout << '0' << endl;
    else cout << '1' << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

struct Card{
  char suit;
  int value;
};


int main(){
  struct Card C1[101], C2[101],key[101];
  int n, i,j,mini,count=0;;
  char ch;

  scanf("%d%c", &n, &ch);
  for ( i = 1; i <= n; i++ ){
    scanf("%c%d%c", &C1[i].suit, &C1[i].value, &ch);
  }

for ( i = 1; i <= n; i++ ){
  C2[i]=C1[i]; 
  }
for(i=1;i<=n;i++){
    for(j=n;j>=i+1;j--){
      if(C1[j].value<C1[j-1].value){
    key[j]=C1[j];
    C1[j]=C1[j-1];
    C1[j-1]=key[j];
    }}}
   for(i=1;i<=n;i++){
if(i==n){
printf("%c%d\n",C1[i].suit,C1[i].value);
    break;
}
 printf("%c%d ",C1[i].suit,C1[i].value);
}
	printf("Stable\n");
	
	
	for(i=1;i<=n;i++){
    mini=i;
    for(j=i;j<=n;j++){
        if(C2[j].value<C2[mini].value){
        mini=j;
        }}         
    if(C2[mini].value<C2[i].value){
    key[i]=C2[i];
    C2[i]=C2[mini];
    C2[mini]=key[i];
    }}
	
	  for(i=1;i<=n;i++){
if(i==n){
printf("%c%d\n",C2[i].suit,C2[i].value);
    break;
}
 printf("%c%d ",C2[i].suit,C2[i].value);
}
for(i=1;i<=n;i++){
	if(C1[i].value==C2[i].value && C1[i].suit==C2[i].suit){
		count++;
		}
else break;
}
	if(count==n) printf("Stable\n");
	else printf("Not stable\n");
	
	
  return 0;}

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

int main(){
  int n, m;
  int data[200020] = {};
  cin >> n >> m;
  int a, b;
  bool flag = false;
  for(int i = 0;i < m;i++){
    cin >> a >> b;
    if(a == 1){
      data[b]++;
      if(data[b] == 2){
        flag = true;
      }
    }else if(b == n){
      data[a]++;
      if(data[a] == 2){
        flag = true;
      }
    }
  }

  if(flag) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;

  return 0;
}

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

int main()
{
    int n;

    cin >> n;

    vector<int> p(n);

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

    int count = 0;
    int sum = 0;
    int adj = 0;

    for (int i = 0; i < n; i++) {
        if (p[i] == i + 1) {
            adj++;
        } else {
            if (adj > 0) {
                count += (adj + 1) / 2;
            }
            adj = 0;
        }
    }
    if (adj > 0) {
        count += (adj + 1) / 2;
    }

    cout << count << endl;


    return 0;
}






Measured memory_bytes: 640
//AnkitCode99 here....
#include<bits/stdc++.h>
#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)
using namespace std;

const ll sz=100005;
const ll szz=1000006;

int main()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("op.txt","w",stdout);
    #endif

    ll n;
    cin>>n;
    //ll ar[n];
    map<ll,ll> mp;
    mp[1]=0;
    rep(i,2,n+1)
    {
        ll ele;
        cin>>ele;
        // cin>>ar[i];
        mp[ele]++;
    }
    rep(i,1,n+1)
    {
        cout<<mp[i]<<endl;
    }
}//Goodbye...

Measured memory_bytes: 16148
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        
        int count = 0;
        for(int i = 0; i < 3; i++){
            for(int j = i + 1; j < 4; j++){
                if( line.charAt(i) == line.charAt(j) ) count++;
            }
        }
        
        System.out.println( (count == 2) ? "Yes" : "No" );
    }
}


Measured memory_bytes: 23892
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;

const long long int mod=1000000007;
const long long int INF=99999999999999999;

string str;
long long int n,k,m,sum,res=0,h[200000];
int main() {
	cout << fixed << setprecision(10);
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>h[i];
		if(h[i]>=k){res++;}
	}
	cout<<res<<endl;
} 


Measured memory_bytes: 1024
def main():
    N = int(input())
    A = str(input())
    B = str(input())
    C = str(input())


    count = 0
    for a, b, c in zip(A, B, C):
        unique_chars_length = len(set([a,b,c]))
        if unique_chars_length == 1:
            # すべて同じ文字のため操作は不要
            pass
        elif unique_chars_length == 2:
            # 文字が２種類存在するため、１回操作が必要
            count += 1
        elif unique_chars_length == 3:
            # 文字が３種類存在するため、２回操作が必要
            count += 2

    print(count)





main()


Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum_s = sum(b)
add_s = sum(c[i1-1] for i1, i2 in zip(a, a[1:]) if i1 + 1 == i2)
print(sum_s + add_s)


Measured memory_bytes: 3060
package main

import (
  "fmt"
  "strconv"
  "strings"
  "os"
  "bufio"
)

func main() {
  var n, m int

  fmt.Scanf("%d %d", &n, &m)
  sc := bufio.NewScanner(os.Stdin)
  sc.Scan()
  s := sc.Text()
  b := stringToSliceInt(s)

  ans := createAnswer(n, b)
  fmt.Println(ans)
}

/**
**/
func createAnswer(n int, b []int) (ans int) {
  x := n
  for _,v := range b {
    x -= v
    if x < 0 {
      ans = -1
      return ans
    }
  }
  ans = x

  return ans
}

// 標準出力の数字一覧を文字列として取得しているので、[]intに変換する
func stringToSliceInt(s string) []int {
  sls := strings.Split(s, " ")
  sli := make([]int, len(sls))
  for i, v := range sls {
    // strconv.Atoi(v string) (int, error)
    // →string型をint型に変換する
    re, _ := strconv.Atoi(v)
    sli[i] = re
  }
  return sli
}


Measured memory_bytes: 2232
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int maxn=2005;
int n,L[maxn],R[maxn],bj[maxn],mx,mi,ans;
int tota,totb,len,que[maxn];
char a[maxn],b[maxn];

int cmpL(int a,int b) {
	return L[a]<L[b];
}

int cmpR(int a,int b) {
	return R[a]<R[b];
}

int main() {
	scanf("%s%s",a+1,b+1); n=strlen(a+1);
	ans=2e9;
	  for (int i=1;i<=n;++i) { 
	  	if (a[i]=='1') tota++;
	  	if (b[i]=='1') totb++; 
	  }
	  if (!totb) { 
	  	if (!tota) return puts("0"),0;
	  	return puts("-1"),0;
	  }
	  for (int i=1;i<=n;++i) { 
	  	int ind=i,cnt=0;
	  	  while (b[ind]!='1') {
	  	  	  ind--; cnt++;
	  	  	  if (ind==0) ind=n;
			}
		L[i]=cnt;
		ind=i; cnt=0;
		  while (b[ind]!='1') {
		  	ind++; cnt++;
		  	if (ind==n+1) ind=1;
		  }
		R[i]=cnt;
	  }
	  for (int i=1;i<=n;++i) { 
	    int ind,sum=0; 
	    if (i==1) ind=1; else ind=n-i+2;
		  for (int j=1;j<=n;++j) bj[j]=0; 
		  for (int j=1;j<=n;++j) {
		  	if (a[ind]!=b[j]) sum++,bj[ind]=1;
		  	ind++; if (ind>n) ind=1;
		  }
		int cnt; 
		  if (i==1) cnt=0; else cnt=n-i+1; 
		len=0;
		  for (int j=1;j<=n;++j) 
		    if (bj[j] && L[j]>cnt) que[++len]=j;
		sort(que+1,que+1+len,cmpR);
		mx=0; mi=2e9;
		  if (len>0) mi=min(mi,R[que[len]]*2+cnt);
		  for (int j=len;j>=1;--j) {
		  	mx=max(mx,L[que[j]]);
		  	if (j>1) mi=min(mi,R[que[j-1]]*2+mx*2-cnt);
		  }
		  if (len>0) mi=min(mi,mx*2-cnt);
		  if (!len) mi=cnt;
		ans=min(ans,mi+sum);
		cnt=i-1; len=0; 
		  for (int j=1;j<=n;++j)
		    if (bj[j] && R[j]>cnt) que[++len]=j;
		sort(que+1,que+1+len,cmpL);
		mx=0; mi=2e9;
		  if (len>0) mi=min(mi,L[que[len]]*2+cnt);
		  for (int j=len;j>=1;--j) {
		  	mx=max(mx,R[que[j]]);
		  	if (j>1) mi=min(mi,L[que[j-1]]*2+mx*2-cnt);
		  }
		  if (len>0) mi=min(mi,mx*2-cnt);
		  if (!len) mi=cnt;
		ans=min(ans,mi+sum);
	  } 
	printf("%d",ans);
	return 0;
} 

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

int main(){
    int n;
    cin >> n;
    vector<int> w(n);
    for (int i = 0; i < n; i++) cin >> w[i];
    vector<int> acc(n+1, 0);
    for (int i = 0; i < n; i++) acc[i+1] = acc[i] + w[i];
    int ans = 1'000'000'000;
    for (int i = 1; i < n; i++){
        ans = min(ans, abs(acc.back() - acc[i]*2));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

int main() {
    ios::sync_with_stdio(false);
    Int a, b;
    cin >> a >> b;
    Int res = 0;
    if (a % 2 == 0 && b % 2 == 1) {
        if ((b - a + 1) / 2 % 2 == 1) res = 1; 
    }
    else if (a % 2 == 0 && b % 2 == 0) {
        if ((b - a) / 2 % 2 == 1) {
            res = b ^ 1LL;
        }
        else {
            res = b;
        }
    }
    else if (a % 2 == 1 && b % 2 == 0) {
        if ((b - a - 1) / 2 % 2 == 1) {
            res = a ^ b ^ 1LL;
        }
        else {
            res = a ^ b;
        }
    }
    else if (a % 2 == 1 && b % 2 == 1) {
        if ((b - a) / 2 % 2 == 1) {
            res = a ^ 1LL;
        }
        else {
            res = a;
        }
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
	double x1, y1, x2, y2, ans;

	cin >> x1 >> y1 >> x2 >> y2;

	ans = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));

	cout << fixed << setprecision(5) <<  ans << endl;

	return 0;
}



Measured memory_bytes: 3284
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  for(int i=0; i<N; i++){
    cin >> v[i];
  }

  map<int,int> odd;
  for(int i=0; i<N; i+=2){
    odd[v[i]]++;
  }
  int odd_maxid=-1,odd_maxv=-1;
  for(auto m:odd){
    if(chmax(odd_maxv,m.second)){
      odd_maxid = m.first;
    };
  }
  int odd_maxv2=-1;
  for(auto m:odd){
    if(m.first == odd_maxid) continue;
    chmax(odd_maxv2,m.second);
  }
  map<int,int> even;
  for(int i=1; i<N; i+=2){
    even[v[i]]++;
  }
  int even_maxid=-1,even_maxv=-1;
  for(auto m:even){
    if(chmax(even_maxv,m.second)){
      even_maxid = m.first;
    };
  }
  int even_maxv2=-1;
  N /= 2;
  for(auto m:even){
    if(m.first == even_maxid) continue;
    chmax(even_maxv2,m.second);
  }
  if(odd_maxid != even_maxid){
    cout << (N-odd_maxv)+(N-even_maxv) << endl;
    return 0;
  }
  if(even_maxv2==-1 && odd_maxv2==-1){
    cout << N << endl;
    return 0;
  }
  if(even_maxv2==-1){
    cout << (N-even_maxv)+(N-odd_maxv2) << endl;
    return 0;
  }
  if(odd_maxv2==-1){
    cout << (N-odd_maxv)+(N-even_maxv2) << endl;
  }
  cout << min((N-even_maxv)+(N-odd_maxv2),(N-odd_maxv)+(N-even_maxv2)) << endl;
  return 0;
}


Measured memory_bytes: 5376
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#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 MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(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 pair<int,int> pii;

signed main(void) {
  int i,j;
  int n,t;
  cin>>n>>t;
  vi a(n);
  rep(i,n)cin>>a[i];
  ll ans=0;
  int x=0;
  loop(i,1,n){
    if(a[i]-a[i-1]<=t)continue;
    ans+=a[i-1]-x+t;
    x=a[i];
  }
  ans+=a[i-1]-x+t;
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k; cin >> n >> k;
  string s; cin >> s;
  char now = s[0];
  int cnt = 1, ans = 0;
  FOR(i, 1, n) {
    if (now != s[i]) {
      ans += cnt - 1;
      cnt = 0;
    }
    now = s[i];
    ++cnt;
  }
  ans += cnt - 1;
  cout << min(ans + k * 2, n - 1) << '\n';
  return 0;
}


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

int main() {
    int N;
    cin>>N;
    vector<int>numbers(N);
    for(int i=0;i<N;i++)
    {cin>>numbers.at(i);}
    int dame=0;
    for(int i=0;i<N;i++)
    {if (numbers.at(i)%2==0&&
         (numbers.at(i)%3!=0&&numbers.at(i)%5!=0)
         )
    {dame++;}
        }
    if(dame>0){cout<<"DENIED"<<endl;}
    else{cout<<"APPROVED"<<endl;}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int h, a;
    cin >> h >> a;
    cout << (h+a-1)/a << endl;
}
    

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int int_vector_find(std::vector<int> vec, int num) {
	auto itr = std::find(vec.begin(), vec.end(), num);
	int index = std::distance(vec.begin(), itr);

	if (index != vec.size()) {
		return 1;
	}
	else {
		return 0;
	}
}

int main() {
	int n, m, c;
	int ans = 0;
	std::cin >> n >> m >> c;
	int b[21];

	for (int i = 0; i < m; ++i) {
		std::cin >> b[i];
	}

	int vec[21][21];

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			std::cin >> vec[i][j];
		}
	}

	for (int i = 0; i < n; ++i) {
		int hoge = 0;
		for (int j = 0; j < m; ++j) {
			hoge += vec[i][j] * b[j];
		}
		if (hoge+c > 0) {
			ans++;
		}
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#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;
constexpr int INF = 2e9;
int main(){ 
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool ok = true;
  int i = 0;
  while (a) {
    if (i % 2 == 0) c -= b;
    else a -= d;
    if (i % 2 == 0) {
      if (c <= 0) {
        break;
      }
    }else {
      if (a <= 0) {
        ok = false;
        break;
      }
    }
    i++;
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
} 

Measured memory_bytes: 3640
#include<stdio.h>
int main(){
    char n[4];
    int s=0,i;
    for(i=0;i<4;i++){
    scanf("%c",&n[i]);
        if(n[i] == '+')
        s=s+1;
        else
        s=s-1;
        }
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
	string o,e;
	cin>>o>>e;
	for(int i=0;i<o.size()+e.size();i++){
		if(i%2==0){
			cout<<o[i/2];
		}
		else if(i%2==1){
			cout<<e[(i-1)/2];
		}
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int fact(int x);

int main()

{
  int n,m,sum,even,odd;
scanf("%d %d",&n,&m);
even=fact(n)/2;
odd=fact(m)/2;
   sum=even+odd;
   printf("%d",sum);
}
int fact(int x){
int c=1;
if(x==0){
   return c;}
    else{
        for(int i=x;i>x-2;i--){
         c=c*i;
        }
    }
        return (c);
}


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

#define fst first
#define snd second
#define mp make_pair
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define per(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

template <typename T1, typename T2>
inline bool umin(T1& x, const T2& y){return x>y ? x=y,true : false;}

template <typename T1, typename T2>
inline bool umax(T1& x, const T2& y){return x<y ? x=y,true : false;}

typedef long long ll;
typedef long double ld;

const int N    = (int)1e6+7;
const int mod  = (int)1e9+7;
const int INF  = (int)1e9+17;
const ll LLINF = (ll)1e18+17;



int n, k;
int h[N];
ll dp[N];


template <typename T>
class MStack {
public:
    MStack() = default;
    void push(const T& x) {
        if (st.empty()) {
            st.emplace_back(x, x);
        } else {
            st.emplace_back(x, min(x, st.back().snd));
        }
    }
    void pop() { st.pop_back(); }
    T top() const { return st.back().fst; }
    T min() const { return st.back().snd; }
    size_t size() const { return st.size(); }
    bool empty() const { return st.empty(); }
private:
    vector<pair<T, T>> st;
};

template <typename T>
class MQueue {
public:
    MQueue() = default;
    void push(const T& x) { add.push(x); }
    void pop() {
        if (rem.empty()) {
            while (!add.empty()) {
                rem.push(add.top());
                add.pop();
            }
            rem.pop();
        }
    }
    T min() const {
        if (!add.empty() && !rem.empty())
            return min(add.min(), rem.min());
        if (!add.empty())
            return rem.min();
        return add.min();
    }
    size_t size() const { return add.size() + rem.size(); }
    bool empty() const { return add.empty() && rem.empty(); }

private:
    MStack<T> add;
    MStack<T> rem;
};


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    #define FILENAME ""
//    freopen(FILENAME".in", "r", stdin);
//    freopen(FILENAME".out", "w", stdout);
#endif

    cin >> n >> k;
    rep(i, 0, n) cin >> h[i];
    fill(dp, dp+n, LLINF);
    dp[0] = 0;
    rep(i, 0, n) rep(j, 1, k+1) {
        umin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
    cout << dp[n-1] << endl;

    return 0;
}


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

int main() {
    int N;
    string S;
    cin >> N >> S;
    vector<int> sum(N);
    int ans = INFINITY;
    int count = 0;
    for (int i = 0; i < N; i++) {
        if (S.at(i) == 'W') count++;
        sum.at(i) = count;
    }
    for (int i = 0; i < N; i++) {
        int ans_i;
        if (i == 0) ans_i =(N - 1 - i) - sum.at(N - 1) + sum.at(i);
        else if (i == N - 1) ans_i = sum.at(i - 1);
        else ans_i = sum.at(i - 1) + (N - 1 - i) - sum.at(N - 1) + sum.at(i);
        ans = min(ans, ans_i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4796
#include <iostream>

int main(){
  int n;
  std::cin >> n;
  unsigned long long ans = 0;
  
  for(int i=1; i<=n; i++){
   	if(i % 3 == 0 || i % 5 == 0 || i % 15 == 0) continue;
    ans += i;
  }
  
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

int main() {
    string s;
    cin >> s;
    int n=s.size();
    if(s[n-1]=='s') s+="es";
    else s+="s";
    cout << s << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    long long int a[n],x,y,tip[100001]={0},i;
    for(i=0;i<n;i++)
    {
    	cin>>a[i];
	}
	for(i=0;i<k;i++)
	{
		cin>>x>>y;
		x--,y--;
		if(a[x]>=a[y])
		{
			tip[y]=1;
		}
		if(a[x]<=a[y])
		{
			tip[x]=1;
		}
	}
	long long int c=n;
	for(i=0;i<n;i++)
	{
		c-=tip[i];
	}
	cout<<c;
		
	}
	

Measured memory_bytes: 5212
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <bitset>

using namespace std;
using ull = unsigned long long;
using ll = long long;

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

#define EPS (1e-7) 
#define ALL(x) begin(x), end(x)

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	for (size_t i = 0; i < N; i++) {
		cin >> A[i];
	}

	// 2の10乗が1024なので、大体10の3乗。2の40乗くらいまで回せば10の12乗カバーできそうだ。
	constexpr ll JOU = 41;

	// 桁DP。[桁][未満フラグ]
	ll dp[JOU + 1][2];
	for (auto&& x: dp) {
		for (auto&& y : x) {
			y = -1; // 初期化
		}
	}

	// 初期状態
	dp[0][0] = 0;
	for (size_t i = 0; i < JOU; i++) {
		const ll mask = 1LL << (JOU - i - 1);

		const ll ones = count_if(ALL(A), [mask](auto a) {
			return (a & mask) != 0;
		});

		// X の i 桁目を 0, 1 にしたときのスコア
		const ll score0 = ones * mask;
		const ll score1 = (N - ones) * mask;

		// smaller -> ?
		if (dp[i][1] != -1) { // smallerフラグONだったら
			chmax(dp[i + 1][1], dp[i][1] + max(score0, score1)); // 次の桁はスコア最大化だけ考えればよい
		}

		// exact -> ?
		if (dp[i][0] != -1) { // smallerフラグOFFだったら
			if ((K & mask) != 0) { // Kが1のとき、
				chmax(dp[i + 1][0], dp[i][0] + score1); // Xを1にするとexact状態の値となる。
				chmax(dp[i + 1][1], dp[i][0] + score0); // Xを0にするとsmaller状態の値となる。
			} else { // Kが0のとき、
				chmax(dp[i + 1][0], dp[i][0] + score0); // Xを0にしなければならない。引き続きexact状態の値となる。
			}
		}
	}
	const ll ans = max(dp[JOU][0], dp[JOU][1]); // スコアが最大になっているほうが良い

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]


def frog(n, k, h):
    d = [float('inf')] * n
    d[0] = 0

    for i in range(1, n):
        d[i] = min(
            d[j] + abs(h[i] - h[j]) for j in range(max(i - k, 0), i)
        )
    return d[n - 1]


print(frog(n, k, h))


Measured memory_bytes: 13980
#include<iostream>
#include<vector>

using namespace std;

int num[300030];//num[x]=x枚以上重複しているカードの種類数
int cnt[300030];//cnt[x]=数xのカードの枚数

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

	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		int x; cin >> x;
		x--;//0-indexedにする(なんとなく)
		cnt[x]++;
	}
	for (int i = 0; i < N; i++) {
		num[cnt[i]]++;
	}
	for (int i = N; i >= 0; i--) {
		num[i] += num[i + 1];//後ろからの累積和
	}

	int sum = N;//使えるカードの枚数
	int c = N;//操作回数
	for (int k = 1; k <= N; k++) {
		//sumがk*c以上になるまでcを減らしていく
		while (sum<k*c) {
			sum -= num[c];//cを1減らすときに、使えるカードの枚数が(重複がc枚以上のカードの種類数)だけ減る
			c--;
		}
		cout << c << endl;
	}
}


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

int main() {
    //O(N)に抑えたい
    //cout << floor(sqrt(3.3)) << endl;

    int n; cin >> n;
    int ans = 0;
    for (int c = 1 ;c <= n - 1; c++){
        int root = floor(sqrt(n-c));
        for ( int a = 1; a <= root; a++) {
            if ((n-c) % a == 0) {
                if ( a * a != ( n - c )) ans += 2;
                else ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3672