akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main()
{
    string s;

    cin >> s;

    int ans = 0;
    REP(i, (s.size() + 1) / 2){
        if(s[i] == 'p')ans--;
    }
    for(int i = (s.size() + 1) / 2; i < s.size(); i++){
        if(s[i] == 'g')ans++;
    }

    cout << ans << endl;
}

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

int main() {
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    vector<unsigned long> p(K);
    copy_n(istream_iterator<unsigned long>(cin), N, back_inserter(p));
    unsigned long mx{0}, now{0};
    for(unsigned long i{K}; i < N + K; ++i)mx = max(mx, now += p[i] - p[i - K]);
    cout << (mx + K) / 2 << ((mx + K) & 1 ? ".5" : "") << endl;
    return 0;
}

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

int n,W,H,x,nx,y,ny,ans,a,b;

int main(){

    cin >> W >> H >> n;
    cin >> x >> y;

    for(int i=1;i<n;i++){
        cin >> nx >> ny;

        if(nx==x&&y==ny);
        else {
                 a=nx,b=ny;
                if(nx>x&&ny>y){
                for(int j=1;j<10111;j++){
                if(nx-j==x||ny-j==y){
                nx=nx-j,ny=ny-j,ans+=j;
                break;
                }
            }
        }else if(nx<x&&ny<y){
                for(int j=1;j<10010;j++){
                if(nx+j==x||ny+j==y){
                nx=nx+j,ny=ny+j,ans+=j;
                break;
                }
            }
        }
        for(int j=1;j<10010;j++){
                if(x==nx)break;
                if(x==nx-j||x==nx+j)ans+=j;
                }
        for(int j=1;j<10010;j++){
                if(y==ny)break;
                if(y==ny-j||y==ny+j)ans+=j;
                }
            }
    x=a,y=b;
    }

    cout << ans << endl;

return 0;
}

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

using namespace std;

typedef long long ll;

class UnionFind {
private:
	vector<int> parent;
	vector<ll> weight;

public:
	UnionFind(int n) {
		parent.resize(n);
		for (int i = 0; i < n; ++i) parent[i] = i;
		weight = vector<ll>(n, 0);
	}
	void unite(int a, int b, int w) {
		int ra = root(a), rb = root(b);
		parent[ra] = rb;
		weight[ra] = w - weight[a] + weight[b];
	}
	int root(int n) {
		if (parent[n] == n) return n;
		else {
			int res = root(parent[n]);
			weight[n] += weight[parent[n]];
			parent[n] = res;
			return res;
		}
	}
	ll getWeight(int n) {
		return weight[root(n)] + weight[n];
	}
	bool isUnited(int a, int b) {
		return root(a) == root(b);
	}
};

int main() {
	int N, M;
	while ( cin >> N >> M, N || M ) {
		UnionFind uf(N);
		for (int q = 0; q < M; ++q) {
			char c; cin >> c;
			if (c == '!') {
				int a, b, dw; cin >> a >> b >> dw; --a, --b;
				uf.unite(a, b, dw);
			}
			else {
				int a, b; cin >> a >> b; --a, --b;
				if (uf.isUnited(a, b)) cout << uf.getWeight(a)-uf.getWeight(b) << endl;
				else cout << "UNKNOWN" << endl;
			}
		}
	}
}

Measured memory_bytes: 4816
#include <cstdio>
#include <iostream>
#include <complex>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl

const double EPS=1e-6;
const double INFTY=1e12;
typedef complex<double> Point;

struct Line{
	Point pos,dir;
	Line(){}
	Line(Point p,Point d):pos(p),dir(d){}
};

int Signum(double x)
{
	return abs(x)<EPS?0:x>0?1:-1;
}

double Dot(Point a,Point b)
{
	return real(conj(a)*b);
}

double Cross(Point a,Point b)
{
	return imag(conj(a)*b);
}

int CCW(Point a,Point b,Point c)
{
	Point d1=b-a,d2=c-a;
	int sign=Signum(Cross(d1,d2));
	
	if(sign)
		return sign;	// 1:ccw,-1:cw
	if(Dot(d1,d2)<-EPS)
		return -2;		// c-a-b
	if(norm(d1)<norm(d2)-EPS)
		return 2;		// a-b-c
	return 0;			// a-c-b
}

// ツ点ツづ陳シツ静シツづ個仰猟猟」
double DistancePL(Point p,Line l)
{
	return abs(Cross(p-l.pos,l.dir))/abs(l.dir);
}
// ツ点ツづ静シツ閉ェツづ個仰猟猟」
double DistancePS(Point p,Line s)
{
	Point a=p-s.pos,b=s.dir;
	Point c=b*Dot(a,b)/norm(b);
	int pos=CCW(Point(0,0),b,c);
	if(pos==-2 || pos==2)
		return min(abs(a),abs(b-a));
	return abs(a-c);
}

void solve(Point p[],Point c,double r)
{
	{	// triangle in circle
		double dist=0;
		for(int i=0;i<3;i++)
			dist=max(dist,norm(p[i]-c));
		if(dist<=r*r){
			puts("b");
			return;
		}
	}
	
	{	// circle in triangle
		bool res=true;
		int ccw=0;
		for(int i=0;i<3;i++){
			int temp=CCW(p[i],p[(i+1)%3],c);
			if(temp==-2 || temp==2)
				continue;
			res&=temp*ccw>=0;
			ccw=temp;
		}
		if(res){
			double dist=INFTY;
			for(int i=0;i<3;i++)
				dist=min(dist,DistancePL(c,Line(p[i],p[(i+1)%3]-p[i])));
			if(Signum(dist-r)>=0){
				puts("a");
				return;
			}
		}
	}
	
	{	// intersect
		double dist=INFTY;
		for(int i=0;i<3;i++)
			dist=min(dist,DistancePS(c,Line(p[i],p[(i+1)%3]-p[i])));
		if(Signum(dist-r)<=0){
			puts("c");
			return;
		}
	}
	
	puts("d");
}

int main()
{
	for(;;){
		Point p[3],c;
		double r;
		for(int i=0;i<3;i++)
			cin>>real(p[i])>>imag(p[i]);
		cin>>real(c)>>imag(c)>>r;
		if(norm(p[0])==0)
			break;
		
		solve(p,c,r);
	}
	
	return 0;
}

Measured memory_bytes: 0
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());




// -----------------------------------------------------------------------

int fre[26];
void solve(){
	string s;	cin>>s;
	for(int i=(int)s.size()-1;i>=0;--i){
		fre[s[i]-'a']++;
	}
	for(int i=0;i<26;++i)
	if(fre[i]&1){
		cout<<"No";
		return ;
	}
	cout<<"Yes";
}


// -----------------------------------------------------------------------


int32_t main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
//	cin>>t;
	while(t--)
	solve();
	return 0;
}


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

int main() {
  int a ,b;
  cin >> a >> b;
  
  if(a*b %2  == 0){
     cout << "Even" << endl;
  }  
  else if (a*b %2  == 1) {
    cout << "Odd" << endl;
  }
}


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

int main() {
	int n;
	cin >> n;
	vector<long long> A(n);
	long long m = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		if (A[i] < m) {
			ans += m - A[i];
			A[i] = m;
		}
		m = A[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
int hat[100500], n = 0;
int x = 0, y = 0;
int tx = 0, ty = 0;
signed main()
{
	scanf("%d", &n), x = n;
	for(int i = 1; i <= n; i++)
		scanf("%d", hat + i), x = min(hat[i], x), y = max(hat[i], y);
	if(x + 1 < y) return (puts("No"), 0);
	for(int i = 1; i <= n; i++)
	{
		if(hat[i] == x) tx++;
		if(hat[i] == y) ty++;
	}
	if(x == y)
	{
		if(x == n - 1 || x <= n / 2) return (puts("Yes"), 0);
		else return (puts("No"), 0);
	}
	else
	{
		if(y <= tx) return (puts("No"), 0);
		if(n < 2 * (y - tx) + tx) return (puts("No"), 0);
		else return (puts("Yes"), 0);
	}
	return 0;
}

Measured memory_bytes: 640
x,k,d = map(int,input().split())

if x < 0:
    x = -x

to_zero = x//d

if k < to_zero:
    print(abs(x - k*d))
    exit()
if (k-to_zero) % 2 == 0:
    print(abs(x-to_zero*d))
else:
    print(abs(x-(to_zero+1)*d))
    

Measured memory_bytes: 9164
import java.util.*;

class Main {
    public static void main(final String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      Set<Integer> d = new TreeSet<>();
      for (int i=0;i<n;i++) {
        int x = sc.nextInt();
        d.add(x);
      }
      System.out.println(d.size());
    }
}

Measured memory_bytes: 23508
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def count(arr, x):
    ans1 = 0
    pre = 0
    N = len(arr)
    for i in range(1, N):
        val = max(0, arr[i - 1] + arr[i] - pre - x)
        if val > arr[i]:
            pre = arr[i]
        else:
            pre = val
        ans1 += val
    return ans1

def run():
    N, x, *A = map(int, read().split())

    print(min(count(A, x), count(A[::-1], x)))

if __name__ == "__main__":
    run()


Measured memory_bytes: 18748
fun main(args: Array<String>) {
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()
    val x = readLine()!!.toInt()
    var count = 0;

    for (i in 0..a) {
        for (j in 0..b) {
            for (k in 0..c) {
               if(x == 500*i + 100*j + 50*k) count++
            }
        }
    }
    println(count)
}

Measured memory_bytes: 31512
#include <iostream>
#include <cstdio>

#include <tr1/unordered_map>

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)


using namespace std;

char d[20][30];

int dx[8] = {-1, 0, 1,-1, 1,-1, 0, 1};
int dy[8] = {-1,-1,-1, 0, 0, 1, 1, 1};

int main(){
  int h, w;

  while(scanf("%d%d", &h, &w), h + w){
    tr1::unordered_map<string, int> m;

    REP(i,h) scanf("%s", d[i]);

    REP(i,h) REP(j,w){
      REP(k,8){
        int x = j;
        int y = i;
        string tmp = "";

        do{
          tmp += d[y][x];
          x = (x + w + dx[k]) % w;
          y = (y + h + dy[k]) % h;
          m[tmp]++;
        }while(i != y || j != x);
      }
    }

    string ans = "";

    FOR(it, m) if(it->second > 1){
      const string &s = it->first;

      if(s.size() > ans.size()) ans = s;
      else if(s.size() == ans.size() && s < ans) ans = s;
    }

    if(ans.size() > 1) puts(ans.c_str());
    else puts("0");
  }

  return 0;
}

Measured memory_bytes: 0
n=gets.to_i
xs=gets.split.map(&:to_i)
xs_ = []
xs.each_with_index do |x,i|
  xs_ << [x,i]
end

xs_.sort_by! {|x,i| x}

ret = Array.new(n)

xs_.each_with_index do |xi,i|
  if i < xs_.length/2
    ret[xi[1]] = xs_[xs_.length/2]
  else
    ret[xi[1]] = xs_[xs_.length/2-1]
  end
end


puts ret.map(&:first).join("\n")

Measured memory_bytes: 38424
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    n = list(input())
    sushi = 0
    for i in n:
        sushi += int(i)
    if int("".join(n)) % sushi == 0:
        print("Yes")
    else:
        print("No")
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 10444
N, M = map(int, input().split())
a = [int(i) for i in input().split()]
xy = [[int(i) for i in input().split()] for _ in range(M)]

class UnionFind() :
    def __init__(self, N) :
        self.parent = [-1] * N
        
    def root(self, x) :
        while self.parent[x] >= 0:
            x = self.parent[x]
        return x

    def unite(self, x, y) :
        rx = self.root(x)
        ry = self.root(y)

        if rx != ry :
            if self.parent[rx] > self.parent[ry] :
                self.parent[rx] = ry
            else :
                if self.parent[rx] == self.parent[ry] :
                    self.parent[rx] -= 1
                self.parent[ry] = rx
    
    def same(self, x, y) :
        return self.root(x) == self.root(y)
        
    def size(self, x) :
        return -self.parent[self.root(x)]
        
UF = UnionFind(N)
for x, y in xy :
    UF.unite(x, y)

component = 0
for p in UF.parent :
    if p < 0 :
        component += 1
        
if N < 2 * (component - 1) :
    print('Impossible')
elif component == 1 :
    print(0)
else :
    ret = 0
    b = [(a[i], UF.root(i)) for i in range(N)]
    b.sort()
    visited = [False] * N
    c = component - 2
    for v, k in b :
        if not visited[k] :
            ret += v
            visited[k] = True
        elif c > 0 :
            ret += v
            c -= 1
            
    print(ret)

Measured memory_bytes: 92568
#include <iostream>
#include <map>
#include <utility>

using namespace std;
int main() {
    int N;
    long long x[50], y[50];
    cin >> N;
    for (int i=0; i<N; i++) cin >> x[i] >> y[i];
    
    map<pair<long long, long long>, int> m;
    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            if (i == j) continue;
            long long p = x[i] - x[j];
            long long q = y[i] - y[j];
            m[make_pair(p, q)]++;
        }
    }
    int maxV = 0;
    for (const auto a : m) {
        int v = a.second;
        if (v > maxV) maxV = v;
    }
    cout << N - maxV << endl;
    return 0;
}



Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <complex>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;


typedef int Key;
typedef int Val;

const int MAX_V = 100000;
const Key INF = 1e9;

struct edge { Key to; Val cost; };

int V;
array<vector<edge>, MAX_V> G;
vector<Val> dist;

void addEdge(const Key& from, const Key& to, const Val& cost){
  G[from].push_back({to, cost});
}

void dijkstra(Key s){
  dist.resize(V);
  typedef pair<Key, Val> P;
  priority_queue<P, vector<P>, greater<P> > que;
  fill(dist.begin(), dist.end(), INF);
  dist[s] = 0;
  que.push(P(0, s));

  while(!que.empty()){
    const auto p = que.top(); que.pop();
    const auto v = p.second;
    if(dist[v] < p.first) continue;
    for(auto e : G[v]){
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        que.push(P(dist[e.to], e.to));
      }
    }
  }
}

int main() {
  int E, r;
  cin >> V >> E >> r;
  for(int i = 0; i < E; ++i) {
    int s, t, d;
    cin >> s >> t >> d;
    addEdge(s, t, d);
  }
  dijkstra(r);
  for(auto d : dist){
    if(d == INF){
      cout << "INF" << endl;
    }else{
      cout << d << endl;
    }
  }

}

Measured memory_bytes: 11300
#include "bits/stdc++.h"
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<double> data(N);
    for(int i = 0; i < N; i++)
    cin >> data.at(i);
    sort(data.begin(), data.end());
    double ave = data.at(0);
    for(int i = 0; i < N; i++){
        ave = (data.at(i) + ave) / 2;
    }
    cout << ave << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}


int main() {
  int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int ans=(h2-h1)*60+(m2-m1)-k;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define REP(i,x) for(int i=0,i##_len=(x);i<i##_len;++i)
#define rep(i,a,b) for(int i=(a),i##_len(b);i<i##_len;++i)
#define All(x) begin(x),end(x)
#define rAll(x) rbegin(x),rend(x)
using namespace std;
using ll = long long;

int main(){
    constexpr ll mod=1e9+7;
    int n,m;cin>>n>>m;
    vector<ll> x(n),y(m);
    REP(i,n) cin>>x[i];
    REP(i,m) cin>>y[i];
    sort(All(x));
    sort(All(y));
    vector<ll> S(n+m);
    REP(i,n) S[i+1]=(S[i]+x[i])%mod;
    vector<ll> sx(n),sy(m);
    REP(i,n) sx[i]=(i*x[i]-S[i]+mod*mod)%mod;
    S[0]=0;
    REP(i,m) S[i+1]=(S[i]+y[i])%mod;
    REP(i,m) sy[i]=(i*y[i]-S[i]+mod*mod)%mod;
    ll Y=0;
    REP(i,m) Y=(Y+sy[i])%mod;
    ll ans=0;
    REP(i,n){
        ans+=sx[i]*Y;
        ans%=mod;
    }
    cout<<ans<<endl;
}


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

int main() {
	int a, b;
	char op;
	while (1) {
		cin >> a >> op >> b;
		if (op == '?') {
			break;
		}
		if (op == '+') {
			cout << a + b << endl;
		}
		if (op == '-') {
			cout << a - b << endl;
		}
		if (op == '*') {
			cout << a * b << endl;
		}
		if (op == '/') {
			cout << a / b << endl;
		}
	}
}


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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c;
    cin>>a>>b>>c;
    if(a==b && a!=c && b!=c)
    {
        cout<<"Yes";
    }
    if(a==c && b!=c && b!=a)
    {
        cout<<"Yes";
    }
    if(c==b && a!=c && b!=a)
    {
        cout<<"Yes";
    }
    if(a==b && b==c && c==a)
    {
        cout<<"No";
    }
    if(a!=b && b!=c && c!=a)
    {
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define ALL(x) begin(x), end(x)
using namespace std;
template <class T> inline void chmax(T & a, T const & b) { a = max(a, b); }
 
int main() {
    // input
    int n; cin >> n;
    vector<int> a0(n); REP (i, n) cin >> a0[i];
    vector<int> a1(n); REP (i, n) cin >> a1[i];
    // solve
    vector<int> acc0(n + 1); partial_sum(ALL(a0), acc0.begin() + 1);
    vector<int> acc1(n + 1); partial_sum(ALL(a1), acc1.begin() + 1);
    int result = 0;
    REP (i, n) {
        chmax(result, (acc0[i + 1] - acc0[0]) + (acc1[n] - acc1[i]));
    }
    // output
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 1005;
const int MAX_dp = 20010;
int A[MAX_N],B[MAX_N];
ll dp[MAX_dp];

int main()
{
	int H,N;
	cin >> H >> N;
	rep(i,N)
	{
		cin >> A[i] >> B[i];
	}
	dp[0] = 0;
	rep(i,MAX_dp-1)
	{
		dp[i+1] = 1e9; 
	}
	rep(i,MAX_dp-1)
	{
		rep(j,N)
		{
			if (i+1 >= A[j])
			{
				dp[i+1] = min(dp[i+1],dp[i+1-A[j]]+B[j]);
			}
		}
	}
	ll ans = 1e9;
	for (int i = H; i < MAX_dp; ++i)
	{
		ans = min(ans,dp[i]);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int M,D;
  cin >> M >> D;
  int cnt = 0;
  for(int j = 1;j<=M;j++){
    
    for(int i = 22;i <= D; i++){
      int D1=0,D2=0;
      D1 = i % 10;
      D2 = i / 10;
      if(D1 < 2){
        continue;
      }
      if(j == D1 * D2){
        cnt++;
//        cout << D1 << " " << D2 << endl;
      }
    }
  }
  cout << cnt << endl;
}


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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    string str,p;
    cin>>str>>p;
    for(int i=0;i<str.size();i++)
    {
        if(str[i]!=p[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
using namespace std;
typedef pair<int ,int > P;
typedef pair<P ,int > Pi;
typedef long long ll;

int w,h;
char s[61][31];
int d[61][31][2];
template<class T>
bool chmin(T &a, const T &b) {
    if(a>b) {
        a=b;
        return true;
    }
    return false;
}

void bfs(int y,int x,int foot) {
    d[y][x][foot]=0;
    queue<Pi> que;
    que.push(Pi(P(y,x),foot));
    while(que.size()) {
        Pi p=que.front();
        que.pop();
        int cur_y=p.fr.fr;
        int cur_x=p.fr.sc;
        int cur_foot=p.sc;
        int a[]={0,2,1,0};
        //printf("[debug] %d %d %d\n",cur_y,cur_x,cur_foot);

        for(int dx=1;dx<=3;dx++) {
            for(int dy=-a[dx];dy<=a[dx];dy++) {
                int ny=dy+cur_y;
                int nx=dx+cur_x;
                if(cur_foot==1) {
                    nx=cur_x-dx;
                }
                if(ny<0 || nx<0) continue;
                if(h<=ny || w<=nx) continue;
                if(s[ny][nx] == 'X') continue;
                if(s[ny][nx] == 'S') continue;

                //printf("[debug] %d %d : %d -> %d %d : %d\n",cur_y,cur_x,d[cur_y][cur_x][cur_foot],ny,nx,d[ny][nx][cur_foot^1]);
                if(s[ny][nx]=='T') {
                    chmin(d[ny][nx][cur_foot^1],d[cur_y][cur_x][cur_foot]);
                }
                else if(chmin(d[ny][nx][cur_foot^1],d[cur_y][cur_x][cur_foot]+s[ny][nx]-'0')) {
                    que.push(Pi(P(ny,nx),cur_foot^1));
                }
            }
        }

    }
}

void solve() {
    rep(y,h) rep(x,w) cin>>s[y][x];
    rep(y,h) rep(x,w) d[y][x][0]=d[y][x][1]=INF;
    rep(y,h) rep(x,w) if(s[y][x]=='S') {
        bfs(y,x,0);
        bfs(y,x,1);
    }
    int ans=INF;
    rep(y,h) rep(x,w) if(s[y][x]=='T') rep(i,2) chmin(ans,d[y][x][i]);

    if(ans==INF) ans=-1;
    cout<<ans<<endl;
}

int main() {
    while(cin>>w>>h) {
        if(!w) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1252
#include <stdio.h>
int main(void){
	int i,N,k,NA,NAA;
	scanf("%d",&N);
	while(N!=0){
		NA=0;
		NAA=0;
		for(i=0;i!=N;i++){
			scanf("%d",&k);
			if(k==1){
				NA++;
			}
			if(k==0){
				NAA++;
			}
		}
		N-=NAA;
		if(N==NA){
			printf("NA\n");
		}
		else{
			N++;
			printf("%d\n",N);
		}
		scanf("%d",&N);
	}
	return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm> 
using namespace std;

int main() {
	int A[110], n, k, ans=0;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < n; i++) {
		if (k - A[i] <= A[i]) {
			ans += 2*(k - A[i]);
		}
		else {
			ans += 2*A[i];
		}
	}
	cout << ans << endl;



	return 0;
}

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

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

	string a;
	cin >> a;

	int ans = 0;
	for(int i = 0; i < (int)a.size(); ++i) {
		string front = a.substr(0, i);
		string back = a.substr(i);
		if(back[0] == '0')
			continue;

		const int m = (i ? stoi(front) : 0);
		const int n = stoi(back);

		const int x2 = n + m;
		const int y2 = n - m;

		if(!(x2 & 1) && !(y2 & 1) && y2 >= 0)
			++ans;
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

const int MAXN=1e5+105;
int dp[MAXN], h[MAXN];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n,k; cin>>n>>k;
    FOR(i,n)
        cin>>h[i];

    memset(dp, 0x7f, sizeof dp);
    dp[0] = 0;

    FOR(i,n) {
        RNG(j,1,k) {
            dp[i+j] |= MIN( dp[i] + abs(h[i+j]-h[i]) );
        }
    }

    cout<<dp[n-1]<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
using namespace std;
int n,dp[50];
int main()
{
	dp[0]=1;
	dp[1]=1;
	for(int i=2;i<=50;i++){
		dp[i]=dp[i-2]+dp[i-1];
	}
	scanf("%d",&n);
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
int C[510], S[510], F[510];

int main() {
   int N;
   cin >> N;
   for (int i = 1; i <= N - 1; i++) {
      cin >> C[i] >> S[i] >> F[i];
   }
   for (int i = 1; i <= N - 1; i++) {
      int ans = 0;
      for (int j = i; j <= N - 1; j++) {
         int m;
         if (ans < S[j]) ans = S[j];
         else if ((ans - S[j]) % F[j] == 0) {
            m = (ans - S[j]) / F[j];
            ans = m * F[j] + S[j];
         } else {
            m = (ans - S[j]) / F[j] + 1;
            ans = m * F[j] + S[j];
         }
         ans += C[j];
      }
      cout << ans << endl;
   }
   cout << 0 << endl;
   return 0;
}


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

int main(){
	int i, j, n, a;
	while(1){
		scanf("%d", &n);
		int sq_num = sqrt((double)n);
		int prime[n];
		if(n == 0){
			break;
		}
		for(i = 0; i < n; i++){
			prime[i] = 1;
		}
		prime[0] = 0;
		for(i = 1; i < sq_num; i++){
			if(prime[i] == 1){
				for(j = (i + 1); (i + 1) * j <= n; j++){
					prime[(i + 1) * j - 1] = 0;
				}
			}
		}
		for(i = 0; i < n - 2; i++){
			if(prime[i] == 1 && prime[i + 2] ==1){
				a = i;
			}
		}
		printf("%d %d\n", a + 1, a + 3);
	}
	return 0;
}

Measured memory_bytes: 636
from collections import deque


def check(s):
    queue = deque()

    for c in s:
        if c == 'B':
            if len(queue) > 0:
                queue.pop()
        else:
            queue.append(c)

    return ''.join(queue)


def main():
    S = input()
    result = check(s=S)
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
//int a[310],b[310],c[310];
int graph[310][310];
int g2[310][310];
signed main(){
    int n,m,l;
    cin>>n>>m>>l;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            graph[i][j]=INF;
            g2[i][j]=INF;
        }
        
    }
    
    for (int i = 0; i < m; i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        
        graph[a][b]=c;
        graph[b][a]=c;
        
      
    }
    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                graph[i][j]=min(graph[i][k]+graph[k][j],graph[i][j]);
             //   g2[i][j]=min(g2[i][k]+g2[k][j],g2[i][j]);
                
            }
            
        }
        
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if(graph[i][j]<=l) g2[i][j]=1;
        }
    }
     for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
               // graph[i][j]=min(graph[i][k]+graph[k][j],graph[i][j]);
                g2[i][j]=min(g2[i][k]+g2[k][j],g2[i][j]);
                
            }
            
        }
        
    }
    int q;
    cin>>q;
    for (int i = 0; i < q; i++)
    {
        int s,t;
        cin>>s>>t;
        s--,t--;
        if(g2[s][t]==INF) cout<<-1<<"\n";
        else {
           cout<<g2[s][t]-1<<"\n";
        
        }
    }
    
   
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}

int main(){
    set<ll>s;
    ll n,t; cin>>n;
    rep(i,n){
        cin>>t;
        s.insert(t);
    }
    if(s.size()==n) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 9600
#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 2e9
#define ll long long
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ALL(v) v.begin(), v.end()

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C; cin >> A >> B >> C;
    if ((A == B) and (B == C)) cout << "Yes" << endl;
    else cout << "No" << endl;
}



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

int val[1 << 20];

void init() {
	for (int i = 1; i <= 1000000; i++) {
		int cx = i;
		while (cx % 2 == 0) { cx /= 2; val[i]++; }
	}
}

bool solve(string S) {
	int r = 0, cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		if (r == 0) cnt += (S[i] - '0');
		r -= val[i + 1];
		r += val[S.size() - i - 1];
	}
	if (cnt % 2 == 0) return false;
	return true;
}

int main() {
	int N; string S; cin >> N >> S; init();
	bool I = solve(S);
	if (I == true) {
		cout << "1" << endl;
	}
	else {
		bool flag = false;
		for (int i = 0; i < S.size(); i++) {
			if (S[i] == '2') flag = true;
		}
		if (flag == true) { cout << "0" << endl; }
		else {
			string T = "";
			for (int i = 0; i < S.size() - 1; i++) {
				if (S[i] == S[i + 1]) T += "0";
				else T += "1";
			}
			bool J = solve(T);
			if (J == true) cout << "2" << endl;
			else cout << "0" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 11060
import math
k = int(input())
a = [int(item) for item in input().split()]
a.reverse()

max_num = 2 
min_num = 2 
for i in range(k):
    if int(math.floor(max_num / a[i])) * a[i] < int(math.ceil(min_num / a[i])) * a[i]:
        print(-1)
        exit()
    next_max = int(math.floor(max_num / a[i])) * a[i] + a[i] - 1
    next_min = int(math.ceil(min_num / a[i])) * a[i]
    max_num = next_max
    min_num = next_min
print(min_num, max_num)

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

int main(){
    int64_t N;
    cin >> N;
    int top = sqrt(N);
    map<int, int> soinsu;
    int i = 2;
    bool flag = false;
    if(N == 1) flag = true;
    while(i<=top){
        if(N % i == 0){
            if(soinsu.count(i) > 0) soinsu.at(i) += 1;
            else soinsu[i] = 1;
            N /= i;
            top = sqrt(N);
        }
        else{
            i++;
        }
    }
    if(N != 1){
       if(soinsu.count(N) > 0) soinsu.at(N) += 1;
        else soinsu[N] = 1;
    }

    if(flag) cout << 0 << endl;
    else if(soinsu.size() == 0) cout << 1 << endl;
    else{
        int count=0;
        int t;
        for(auto itr = soinsu.begin(); itr != soinsu.end(); ++itr) {
            t = 1;
            while(true){
                if(itr->second < t) break;
                else{
                    itr->second -= t;
                    t++;
                    count++;
                }
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 3692
package main

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

var (
	rdr   = bufio.NewReaderSize(os.Stdin, 1000000)
	reply string
)

func main() {
	in := nextSlice()
	solve(in)
}

func solve(buf []string) {
	var (
		k, _ = strconv.Atoi(buf[0])
		x, _ = strconv.Atoi(buf[1])
	)
	yesOrNo(k*500 >= x)
}

func point(points []int, s string) (point int) {
	switch s {
	case "r":
		point = points[2]
	case "s":
		point = points[0]
	case "p":
		point = points[1]
	}
	return
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

// ---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

// ---------------------------------------------------

func yesOrNo(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

func yesorNO(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxn = 2e5 + 5;

int n;
int x[maxn], y[maxn], xr[maxn], yr[maxn], p[maxn], q[maxn], ans[maxn], l[maxn], r[maxn], u[maxn], d[maxn];

class DSU{
public:
	int fa[maxn], sz[maxn];
	inline void init(){ FOR(i, 0, maxn) fa[i] = i, sz[i] = 1; return; }
	inline int find(int x){ return (x == fa[x] ? fa[x] : fa[x] = find(fa[x])); }
	inline void combine(int x, int y){
		x = find(x), y = find(y);
		if(x == y)
			return;
		fa[x] = y;
		sz[y] += sz[x];
		return; 
	}
}dsu;

int main(){
	scanf("%d", &n);
	FOR(i, 0, n){
		scanf("%d%d", x + i, y + i);
		--x[i]; --y[i];
		xr[x[i]] = i; yr[y[i]] = i;
		p[x[i]] = y[i];
		q[y[i]] = x[i];
	}
	
	dsu.init();

	pii val = MP(n, -1);
	FOR(i, 0, n){
		int id = xr[i];
		val = min(val, MP(y[id], id));
		dsu.combine(id, val.snd);
	}
	val = MP(n, -1);
	FOR(i, 0, n){
		int id = yr[i];
		val = min(val, MP(x[id], id));
		dsu.combine(id, val.snd);
	}
	val = MP(-1, -1);
	for(int i = n - 1; i >= 0; --i){
		int id = yr[i];
		val = max(val, MP(x[id], id));
		dsu.combine(id, val.snd);
	}
	val = MP(-1, -1);
	for(int i = n - 1; i >= 0; --i){
		int id = xr[i];
		val = max(val, MP(y[id], id));
		dsu.combine(id, val.snd);
	}
	
	FOR(i, 0, n)
		printf("%d\n", dsu.sz[dsu.find(i)]);
	return 0;
}


Measured memory_bytes: 10040
#include  <functional>
#include  <algorithm>
#include  <exception>
#include  <stdexcept>
#include  <streambuf>
#include  <iterator>
#include  <string.h>
#include  <stdlib.h>
#include  <typeinfo>
#include  <valarray>
#include  <iostream>
#include  <sstream>
#include  <istream>
#include  <stdio.h>
#include  <climits>
#include  <clocale>
#include  <complex>
#include  <csetjmp>
#include  <csignal>
#include  <cstdarg>
#include  <cstddef>
#include  <ctype.h>
#include  <cassert>
#include  <cstdlib>
#include  <utility>
#include  <cstring>
#include  <numeric>
#include  <ostream>
#include  <cwctype>
#include  <fstream>
#include  <iomanip>
#include  <math.h>
#include  <bitset>
#include  <cctype>
#include  <string>
#include  <vector>
#include  <limits>
#include  <memory>
#include  <cerrno>
#include  <time.h>
#include  <iosfwd>
#include  <cfloat>
#include  <cstdio>
#include  <cwchar>
#include  <cmath>
#include  <ctime>
#include  <deque>
#include  <queue>
#include  <stack>
#include  <ios>
#include  <map>
#include  <set>
#include  <new>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define pii pair<int,int>
using namespace std;
const int maxn=3005;
int n,a[maxn];
ll ans=-1;
ll maxx;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        maxx+=a[i];
    }
    ans=maxx-n;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;
  FOR(i,0,N-1) {
    if (S[i] != S[i+1]) {
      ans++;
    }
  }
  cout << ans + 1 << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int d[105],l[105];
int main()
{
	int n,x,i,j;
	while(~scanf("%d%d",&n,&x))
	{
		int sum=0;
		for(i=1;i<=n;i++)
		    scanf("%d",&l[i]);
		d[1]=0;
		for(j=2;j<=n+1;j++)
		    d[j]=d[j-1]+l[j-1];
		for(i=1;i<=n+1;i++)
		    if(x>=d[i])sum++;
		    else break;
		printf("%d\n",sum);
	}
}//

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int h,w,a,b;

int main(){
	cin>>h>>w>>a>>b;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if((i<b)^(j<a)){
				cout<<1;
			}else{
				cout<<0;
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
using System;

public class Hello
{
    public static void Main()
    {
        var x = int.Parse(Console.ReadLine().Trim());
        Console.WriteLine(getAns(x));
    }
    static int getAns(int x)
    {
        if (x <= 99) return 0;
        if (x <= 105) return 1;
        var dp = new bool[x + 1];
        dp[0] = true;
        for (int i = 100; i <= 105; i++) dp[i] = true;
        for (int i = 106; i <= x; i++)
            for (int j = 100; j <= 105; j++)
                if (dp[i - j]) { dp[i] = true; break; }
        return dp[x] ? 1 : 0;
    }
}


Measured memory_bytes: 13140
import sys
import math
readline = sys.stdin.readline


def main():
    a, b, h, m = map(int, readline().rstrip().split())
    pi = math.pi
    aArg = (60 * h + m) * pi / 360
    bArg = m * pi / 30
    print(((a * math.cos(aArg) - b * math.cos(bArg)) ** 2 +
           (a * math.sin(aArg) - b * math.sin(bArg)) ** 2) ** 0.5)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9588
#include<cstdio>
#include<algorithm>
#define MN 2100001
using namespace std;

int n,m,a[MN];
long long sum1=0,sum2=0,mmh=1e18;
long long _abs(long long x){return x<0?-x:x;}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum2+=a[i];
	for (int i=1;i<n;i++) if (sum1+=a[i],_abs(sum2-sum1-sum1)<mmh) mmh=abs(sum2-sum1-sum1);
	printf("%d\n",mmh);
} 

Measured memory_bytes: 896
// g++ -I ~/Documents/programming/cppLib -std=gnu++14 -o test ~/Documents/programming/cppLib/test.cpp && ./test && rm test
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vector2 = vector <vector  <T>>;
template <typename T> using vector3 = vector <vector2 <T>>;
template <typename T> using vector4 = vector <vector3 <T>>;
using lint = long long;
#define REP( i, n )    for( lint i= 0  ; i <  (n) ; ++i )
#define ALL( v )       (v).begin(), (v).end()

//	modNの計算をするクラス
template <int mod>
struct mint{
    int data;
    mint( void ) :data(0) {}
    mint( int n ) :data(n % mod) {}
    operator int() { return data; }
    friend istream &operator>>(istream&is,mint&m){int n; is>>n; m=n; return is;}
    friend ostream &operator<<(ostream&os,mint&m){os<<(int)m; return os;}
    mint operator+ ( int n ) { return (data + n) % mod; }
    mint operator+ (mint m ) { return *this + (int)m; }
    void operator+=( int n ) { data = *this +      n; }
    void operator+=(mint m ) { data = *this + (int)m; }
    mint operator* ( int n ) { return (lint)data * n % mod; }
    mint operator* (mint m ) { return *this * (int)m; }
    void operator*=( int n ) { data = *this *      n; }
    void operator*=(mint m ) { data = *this * (int)m; }
    bool operator==( int n ) { return data == n; }
    bool operator==(mint m ) { return data == m.data; }
    bool operator!=( int n ) { return data != n; }
    bool operator!=(mint m ) { return data != m.data; }
    mint pow(int n){mint a=1,b=data;while(n>0){if(n&1)a*=b;b*=b;n>>=1;}return a;}
    mint pow(mint m){ return (*this).pow((int)m); }
};
using mint_7 = mint<1000000007>;
using mint_9 = mint<1000000009>;


int main() {
    int N, M;
    cin >> N >> M;

    vector<bool> braken(N, false);
    REP( i, M ) {
        int a;
        cin >> a;
        braken[a] = true;
    }

    vector<mint_7> dp(N);
    dp[0] = 1;
    dp[1] = braken[1] ? 0 : 1;
    for( int i=2; i<N; i++ ) {
        dp[i] = braken[i] ? mint_7(0) : dp[i-1] + dp[i-2];
    }

    cout << dp[N-1] + dp[N-2] << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>


using namespace std;
using Graph = vector<vector <bool>>;

int main(){
    int n, ans;
    cin >> n;
    map<string, int> mp;
    for(int i=0; i<n; i++){
        string str;
        cin >> str;
        mp[str]++;
    }
    ans = mp.size();
    cout << ans << endl;
    
}


Measured memory_bytes: 19204
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(int n=scanner.nextInt(); n>0; n--)
		{
			int score = 0;
			int runner = 0;
			int out_count = 0;
			
			for(; ;)
			{
				String batter = scanner.next();
				if(batter.equals("HIT"))
				{
					runner ++;
					if(runner == 4)
					{
						score ++;
						runner = 3;
					}
				}
				else if(batter.equals("OUT"))
				{
					out_count ++;
					if(out_count == 3)
					{
						break;
					}
				}
				else if(batter.equals("HOMERUN"))
				{
					score += runner+1;
					runner = 0;
				}
			}
			
			System.out.println(score);
		}
	}
}

Measured memory_bytes: 26348