akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

type edge struct {
	toNode, weight int
}

type node struct {
	dist    int
	visited bool
	next    []edge
}

type graph []node

func dfs(G *graph, x int) {
	(*G)[x].visited = true
	for _, edge := range (*G)[x].next {
		u := edge.toNode
		w := edge.weight
		if !(*G)[u].visited {
			(*G)[u].dist = (*G)[x].dist + w
			dfs(G, u)
		}
	}

}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	G := make(graph, N)

	for i := 0; i < N-1; i++ {
		u, v, w := scanInt(), scanInt(), scanInt()
		G[u-1].next = append(G[u-1].next, edge{toNode: v - 1, weight: w})
		G[v-1].next = append(G[v-1].next, edge{toNode: u - 1, weight: w})
	}
	dfs(&G, 0)

	for _, node := range G {
		fmt.Println(node.dist % 2)
	}
}


Measured memory_bytes: 24064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define INF 1e18
#define M 1000000009
#define pi 3.14159265358979323846264338327950
typedef pair<int,int> pr;
#define N 1000002
signed main()
{
    SPEED;
  	int n;
  	cin>>n;
  	int a[n],ans=1;
  	for(int i=0;i<n;++i)
    {
      	cin>>a[i];
    }
  	sort(a,a+n);
  	if(a[0]==0)
    {
      cout<<0;
      return 0;
    }
  	for(int i=0;i<n;++i)
    {
       if (ans > (1000000000000000000 / a[i])) {
            cout<<-1;
          return 0;
        }
     	ans*=a[i];
    }
  	cout<<ans;
}

Measured memory_bytes: 4440
n = int(input())
s = input()

left = 0
leftplus = 0
for i in range(len(s)):
    if s[i] == '(':
        left += 1
    else:
        if left == 0:
            leftplus += 1
        else:
            left -= 1

right = 0
rightplus = 0
r = s[::-1]
for i in range(len(r)):
    if r[i] == ')':
        right += 1
    else:
        if right == 0:
            rightplus += 1
        else:
            right -= 1
print('('*leftplus + s + ')'*rightplus)

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef pair<int,int> ii;
const int IINF = INT_MAX;

vector<ii> G[100010];
int mincost[100010];
int V,E,r;

int main(){
  scanf("%d %d %d",&V,&E,&r);

  int s,t,d;
  rep(i,E){
    scanf("%d %d %d",&s,&t,&d);
    G[s].push_back(ii(t,d));
  }

  rep(i,V) mincost[i] = IINF;
  mincost[r] = 0;
  deque<int> deq; deq.push_back(r);
  vector<int> in_queue(V,0); in_queue[r] = 1;

  while(!deq.empty()){
    int u = deq.front(); deq.pop_front(); in_queue[u] = 0;
    rep(i,(int)G[u].size()){
      int v = G[u][i].first, c = G[u][i].second;
      if( mincost[v] > mincost[u] + c ) {
        mincost[v] = mincost[u] + c;
        if( !in_queue[v] ) {
          deq.push_back(v);
          in_queue[v] = 1;
        }
      }
    }
  }

  rep(i,V) {
    if( mincost[i] == IINF ) puts("INF");
    else printf("%d\n",mincost[i]);
  }

  return 0;
}

Measured memory_bytes: 11064
#include <stdio.h>

int i,ans ;
char s[4] ;

int main(void){

    scanf ("%s",s) ;
    
    for(i=0; i<4; i++){
        if (s[i]=='+'){
            ans++ ;
        }
        else{
            ans-- ;
        }
    }

    printf ("%d",ans) ;

    return 0 ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main(){
    speed;
    int n; cin >> n;
    vi v(n);
    forn(n) cin >> v[i];
    sort(all(v));
    for(int i = 0; i < n / 2; i++) {
        swap(v[i], v[n - 1 - i]);
    }
    ll res = 0;
    int k = n / 2;
    if(n % 2 == 0) k--;
    for(int i = 0; i < k; i++) {
        res += v[i];
    }
    if(n % 2 == 0) {
        for(int i = 1; i < k + 1; i++) {
            res += v[i];
        }
        res += v[k];
    }
    else {
        for(int i = 1; i < k + 1; i++) {
            res += v[i];
        }
    }

    cout << res;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int A, B, C, D;
  A = N/1000;
  B = N%1000 /100;
  C = N%100 / 10;
  D = N%10;
  if (A+B+C+D == 7) {
    cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
    return 0;
  }
  else if (A+B+C-D == 7) {
    cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
    return 0;
  }
  else if (A+B-C+D == 7) {
    cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
    return 0;
  }
  else if (A-B+C+D == 7) {
    cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
    return 0;
  }
  else if (A+B-C-D == 7) {
    cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
    return 0;
  }
  else if (A-B+C-D == 7) {
    cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
    return 0;
  }
  else if (A-B-C+D == 7) {
    cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
    return 0;
  }
  else if (A-B-C-D == 7) {
    cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int MAX = (2e5)+1;

int n, p[MAX], pos[MAX];
vector<int> res;
priority_queue<pair<pii, pii> > pq;

struct segment_tree {
	int mod, t[2*MAX];
	void build() {
		for(int i = 0; i < n; i++) t[i + n] = (i % 2 == mod ? p[i] : INT_MAX);
		for(int i = n-1; i >= 1; i--) t[i] = min(t[i<<1], t[i<<1|1]);
	}
	int query(int l, int r) {
		++r;
		int ret = INT_MAX;
		for(l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if(l & 1) ret = min(t[l++], ret);
			if(r & 1) ret = min(t[--r], ret);
		}
		return ret;
	}
} st[2];

pii getxy(int l, int r) {
	int x = st[l % 2].query(l, r);
	int y = st[l % 2 ^ 1].query(pos[x]+1, r);
	return make_pair(-x, -y);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	st[0].mod = 0, st[1].mod = 1;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> p[i];
		pos[p[i]] = i;
	}

	st[0].build();
	st[1].build();
	pq.emplace(make_pair(getxy(0, n-1), make_pair(0, n-1)));
	for(int l, r, x, y; !pq.empty(); ) {
		tie(x, y) = pq.top().first; x = -x; y = -y;
		tie(l, r) = pq.top().second;
		pq.pop();
		res.push_back(x);
		res.push_back(y);
		x = pos[x], y = pos[y];
		if(x+1 < y-1) pq.emplace(make_pair(getxy(x+1, y-1), make_pair(x+1, y-1)));
		if(l < x-1) pq.emplace(make_pair(getxy(l, x-1), make_pair(l, x-1)));
		if(y+1 < r) pq.emplace(make_pair(getxy(y+1, r), make_pair(y+1,r)));
	}
	for(int i = 0; i < n; i++) cout << res[i] << ' ';
}


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

using namespace std;
typedef long long ll;

bool pred(ll cond, ll target)
{
  return cond <= target;
}

int main() 
{
  int n, m, k;
  cin >> n >> m >> k;
  vector<ll> newB(m + 1), newA(n + 1);
  newA[0] = newB[0] = 0;
  for( int i = 0; i < n; ++i )
  {
    cin >> newA[i + 1];
    newA[i + 1] += newA[i];
  }

  for( int i = 0; i < m; ++i )
  {
    cin >> newB[i + 1];
    newB[i + 1] += newB[i];
  }

  int maxi = 0;
  for( int i = 0; i <= n; ++i )
  {
    if ( newA[i] > k ) continue;
    int lo = 0, hi = m, j;
    ll target = k - newA[i];
    if ( !pred(newB[lo], target) ) j = lo;

    else if ( pred(newB[hi], target) ) j = hi;
    else
    {
      while(hi - lo > 1)
      {
        int mi = lo + (hi - lo) / 2;
        if ( pred(newB[mi], target) ) lo = mi;
        else hi = mi;
      }
      j = lo;
    }

    maxi = max(maxi, i + j);
  }
  
  cout << maxi;
  return 0;
}

Measured memory_bytes: 6376
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,q;
  cin>>n>>k>>q;
  vector<int> a(q);
  vector<int> ans(n,k-q);
  for(int i=0;i<q;i++){
    cin>>a.at(i);
    a.at(i)--;
    ans.at(a.at(i))++;
  }
  for(int i=0;i<n;i++){
    if(ans.at(i)>0){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
    
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define int long long

using namespace std;
vector<vector<int > >adj;
int n,k;
int ans;
int mod=1e9+7;
int fac[100005];
bool flag=true;

int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        // q is quotient
        int q = a / m;
        int t = m;

        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;

        // Update y and x
        y = x - q * y;
        x = t;
    }

    // Make x positive
    if (x < 0)
        x += m0;

    return x;
}
int comp(int a,int b)
{
    if(a<b)
        return 0;
    else if(a<=0)
        return 0;
    else if(b<0)
        return 0;
    int z=fac[a];
    z=(z*modInverse(fac[a-b],mod))%mod;
    return z;
}

void dfs(int i,int p)
{
    if(i==1)
    {
        int z=adj[i].size();
        ans=(ans*comp(k-1,z))%mod;
    }
    else
    {
        int z=adj[i].size();
        if(z==1)
            return;
        z--;
        ans=(ans*comp(k-2,z))%mod;
    }
    for(auto j:adj[i])
    {
        if(j!=p)
            dfs(j,i);
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>k;
    int x,y;
    ans=k;
    adj.resize(n+1);
    fac[0]=1;
    for(int i=1;i<=100000;i++)
    {
        fac[i]=(fac[i-1]*i)%mod;
    }

    for (int i = 0; i < n-1; ++i) {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    if(n==1)
    {
        cout<<k;
        return 0;
    }
    dfs(1,0);
    cout<<ans;
}

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

using namespace std;

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

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vl> mat;

int N;
ll K;
mat trans;
ll ans;

mat mat_mul(mat a, mat b)
{
	mat res(N);
	FOR(i, 0, N) res[i].resize(N);
	FOR(i, 0, N)
	{
		FOR(j, 0, N)
		{
			FOR(k, 0, N)
			{
				res[i][j] += a[i][k] * b[k][j];
				res[i][j] %= INF;
			}
		}
	}
	return res;
}
mat mat_expo(mat a, ll e)
{
	if (e == 1) return a;
	if (e & 1)
	{
		return mat_mul(mat_expo(mat_mul(a, a), e >> 1), a);
	}
	return mat_expo(mat_mul(a, a), e >> 1);
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> K;
	trans.resize(N);
	FOR(i, 0, N) trans[i].resize(N);
	FOR(i, 0, N)
	{
		FOR(j, 0, N)
		{
			cin >> trans[i][j];
		}
	}
	trans = mat_expo(trans, K);
	FOR(i, 0, N)
	{
		FOR(j, 0, N)
		{
			ans += trans[i][j];
			ans %= INF;
		}
	}
	cout << ans << '\n';
	return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

struct SegmentTree {
private:
  int n;
  vector<ll> node;

public:
    // 元配列 v をセグメント木で表現する
  SegmentTree(vector<ll> v) {
    // 最下段のノード数は元配列のサイズ以上になる最小の 2 冪 -> これを n とおく
    // セグメント木全体で必要なノード数は 2n-1 個である
    int sz = v.size();
    n = 1; while(n < sz) n *= 2;
    node.resize(2*n-1, 0); // 最小値は0

    // 最下段に値を入れたあとに、下の段から順番に値を入れる
    // 値を入れるには、自分の子の 2 値を参照すれば良い
    for(int i=0; i<sz; i++) node[i+n-1] = v[i];
    for(int i=n-2; i>=0; i--) node[i] = max(node[2*i+1], node[2*i+2]);
  }

  void update(int x, ll val) {
    // 最下段のノードにアクセスする
    x += (n - 1);

    // 最下段のノードを更新したら、あとは親に上って更新していく
    node[x] = val;
    while(x > 0) {
      x = (x - 1) / 2;
      node[x] = max(node[2*x+1], node[2*x+2]);
    }
  }

    // 要求区間 [a, b) 中の要素の最大値を答える
    // k := 自分がいるノードのインデックス
    // 対象区間は [l, r) にあたる
  ll getmax(int a, int b, int k=0, int l=0, int r=-1) {
    // 最初に呼び出されたときの対象区間は [0, n)
    if(r < 0) r = n;

    // 要求区間と対象区間が交わらない -> 適当に返す
    if(r <= a || b <= l) return 0;

    // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
    if(a <= l && r <= b) return node[k];

    // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
    // 左側の子を vl ・ 右側の子を vr としている
    // 新しい対象区間は、現在の対象区間を半分に割ったもの
    ll vl = getmax(a, b, 2*k+1, l, (l+r)/2);
    ll vr = getmax(a, b, 2*k+2, (l+r)/2, r);
    return max(vl, vr);
  }
};


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

  int N;
  cin >> N;
  vector<int> h(N);
  rep(i, N){
    cin >> h[i];
    h[i]--;
  }

  vector<ll> a(N);
  rep(i, N) cin >> a[i];

  vector<ll> ans(N);
  rep(i, N) ans[i] = 0;

  SegmentTree segtree(ans);

  rep(i, N){

    ll max_val = segtree.getmax(0, h[i]);

    ll tmp_ans = a[i] + max_val;

    segtree.update(h[i], tmp_ans);

  }

  cout << segtree.getmax(0, N) << endl;

  return 0;
}


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

int main(){
    ll n,m;
    cin >> n >> m;
    vector <ll> x(m);
    ll xx;
    x[0]=0;
    rep(i,m){
        cin >> x[i];
    }
    sort(x.begin(),x.end());
    vector <ll> sa(m-1);
    rep(i,m-1){
        sa[i]=x[i+1]-x[i];
    }
    sort(sa.begin(),sa.end());
    if(n>=m){
        cout << 0 << endl;
    }
    else{
        ll ans=0;
        rep(i,m-n){
            ans+=sa[i];
        }
        cout << ans << endl;
    }

    

    return 0;
}

Measured memory_bytes: 4684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

#define INF 1LL << 60
#define pb push_back
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)

int main() {
    int N, H[25];
    cin >> N;
    REP(i, N) cin >> H[i];

    int M = 0;
    int ans = 0;
    REP(i, N) {
        if (M <= H[i]) {
            ans++;
            M = H[i];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 10000000
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class edge{
public:
	int u,v,t,c;
	edge(){}
	edge(int uu,int vv,int tt,int cc){
		u=uu;
		v=vv;
		t=tt;
		c=cc;
	}
	bool operator<(const edge &e)const{
		return t<e.t;
	}
};

class data{
public:
	int v,t,c;
	data(){}
	data(int vv,int tt,int cc){
		v=vv;
		t=tt;
		c=cc;
	}
	bool operator<(const data &d)const{
		return d.t<t;
	}
};
int n,m,s,g;
int dp[100001];
int prev[100001];
vector<edge> G;

int main(void){
	scanf("%d%d%d%d",&n,&m,&s,&g);
	s--;
	g--;
	for(int i=0;i<m;i++){
		int u,v,t,c;
		scanf("%d%d%d%d",&u,&v,&t,&c);
		u--;
		v--;
		G.push_back(edge(u,v,t,c));
	}
	sort(G.begin(),G.end());
	priority_queue<data> que;
	for(int i=0;i<n;i++){
		dp[i]=INF;
	}
	dp[s]=0;
	int res=INF;
	for(int i=0;i<m;i++){
		edge e=G[i];
		while(1){
			if(!que.size())break;
			data q=que.top();
			if(q.t<=e.t){
				if(dp[q.v]+e.t-prev[q.v]>q.c){
					dp[q.v]=q.c;
					prev[q.v]=q.t;
				}
				que.pop();
			}else break;
		}
		if(e.u==g)res=min(dp[e.u],res);
		if(dp[e.u]!=INF){
			dp[e.u]=dp[e.u]+e.t-prev[e.u];
			prev[e.u]=e.t;
			que.push(data(e.v,e.t+e.c,dp[e.u]));
		}
	}
	while(que.size()){
		data q=que.top();
		que.pop();
		if(dp[q.v]>q.c){
			dp[q.v]=q.c;
		}
	}
	printf("%d\n",min(res,dp[g]));
	return 0;
}

Measured memory_bytes: 8496
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    string ans;
    for (int i=0;i<s.size();i++) {
        if (s.at(i)=='0') {
            ans=ans+"0";
        } else if (s.at(i)=='1') {
            ans=ans+"1";
        } else {
            if (ans.empty()!=true) {
                ans.erase(ans.size()-1);
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
template<class T> void read(T &x)
{
    x=0; int f=1,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=getchar();}
    x*=f;
}
template<class T> inline bool Cmax(T &x,T y) {return x<y?x=y,1:0;}
const int maxn=3000+50;
int n;
int a[maxn],b[maxn],bel[maxn<<1];
char s[maxn<<1];
string an;
void sol(int L,int R)
{
    string re;
    int l=1; while(a[l]<L) ++l;
    int r=n; while(a[r]>R) --r;
    if(s[L]=='a')
    {
        int cnt=1,k=l;
        for(int i=l;i<=r;++i)
        {
            if(a[i]>b[k]) ++cnt,k=i;
        }
        while(cnt--) re.push_back('a'),re.push_back('b');
    }
    else
    {
        for(int i=l;i<=r;++i)
        {
            string now; 
            for(int j=b[i];j<=R;++j) if(bel[j]>=i) now.push_back(s[j]);
            Cmax(re,now);
        }
    }
    // cerr<<L<<' '<<R<<' '<<l<<' '<<r<<' '<<re<<endl;
    if(re+an>an) an=re+an;
}
int main()
{
    read(n);
    scanf("%s",s+1);
    for(int i=1,x=0,y=0;i<=(n<<1);++i)
    {
        if(s[i]=='a') a[++x]=i,bel[i]=x;
        else b[++y]=i,bel[i]=y;
    }
    for(int i=(n<<1),cnt=0,las=(n<<1);i>=1;--i)
    {
        if(s[i]=='a') ++cnt; else --cnt;
        if(cnt==0)
        {
            sol(i,las);
            las=i-1;
        }
    }
    cout<<an<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main() {
	int n, d[20], sum = 0, tmp, tmp2;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &d[i]);
	}
	for(int i = 0; i < n; i++) {
		scanf("%d", &tmp);
		if ((tmp2 = d[i] - tmp) > 0){
			sum += tmp2;
		}
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>

using namespace std;
            
int main(){

    int n;
    int x ,y ,z;
    cin >> n;
    
    for(int i = 0; i < n; ++i){
	    cin >> x >> y >> z;
        if( x * x + y * y == z * z ||
            x * x + z * z == y * y ||
            z * z + y * y == x * x ){
            cout << "YES";
        }else{
              cout << "NO";
        }
        cout << endl;
	}
    
	return 0;
}

Measured memory_bytes: 1152
<?php
$time=trim(fgets(STDIN));
$array=str_split(trim(fgets(STDIN)));

$max = 0;
$result = 0;

for($i=0;$i<$time;$i++){
    
    if($array[$i]=="I"){
        $result++;
    }elseif($array[$i]=="D"){
        $result--;
    }
    
    if($max<$result){
        $max=$result;
    }
}

echo $max;
?>

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

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

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

struct UnionFind {
  vector<int> parent;
  vector<int> num_node;

  UnionFind(int N) : parent(N), num_node(N, 1) {
    for (int i = 0; i < N; i++) {
      parent[i] = i;
    }
  }

  // 根を求める
  int root(int x) {
    if (parent[x] == x) {
      return x;
    }

    // 経路圧縮
    parent[x] = root(parent[x]);
    return parent[x];
  }

  // 同一判定
  bool is_same(int x, int y) {
    return this->root(x) == this->root(y);
  }

  // 併合
  void unite(int x, int y) {
    x = this->root(x);
    y = this->root(y);

    // すでに一緒ならなにもしない
    if (x == y) {
      return;
    }
    parent[x] = y;
    num_node[y] += num_node[x];
  }

  // 同一グループのノード数
  int size(int x) {
    return num_node[root(x)];
  }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, m;
  cin >> n >> m;

  UnionFind uf(n);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
  }

  ll ans = 1;
  rep(i, n) {
    chmax(ans, (ll)uf.size(i));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 10940
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int x;
  cin >> x;
  for(int i=-1000;i<=1000;i++){
    for(int j=-1000;j<=1000;j++){
      if(i*i*i*i*i-j*j*j*j*j==x){
        cout << i << " " << j;
        return 0;
      }
    }
  }
}

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

int main(){
  std::string s;
  std::cin >> s;
  std::string d("LR");
  int m = 0;
  for(auto i : s)
    if(i == d[m%2]){
      std::cout << "No" << std::endl;
  	  return 0;
    }
  	else
      ++m;
  std::cout << "Yes" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int main() {
  //
  int x;
  cin >> x;
  if (400 <= x && x <= 599) {
    cout << 8;
  } else if (x <= 799) {
    cout << 7;
  } else if (x <= 999) {
    cout << 6;
  } else if (x <= 1199) {
    cout << 5;
  } else if (x <= 1399) {
    cout << 4;
  } else if (x <= 1599) {
    cout << 3;
  } else if (x <= 1799) {
    cout << 2;
  } else {
    cout << 1;
  }
}


Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
N,M,X=input().split()

A=[]
C=[]


for i in range(int(N)):
    S=input().split()
    C.append(int(S[0]))
    A.append([int(a) for a in S[1:]])

L=2**int(N)
ans=[]
for i in range(L):
    D=[0]*int(M)
    Z='{:012b}'.format(i)
    c=0
    for j in range(int(N)):
        if int(Z[11-j])==1:
            c+=C[j]
            for m in range(int(M)):
                D[m]+=A[j][m]           
    if min(D)>=int(X):
        ans.append(c)

#print(ans)
if ans==[]:
    ans=-1
else:
    ans=min(ans)

print(ans)

Measured memory_bytes: 9252
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>

int main()
{
    int k, ans;
    std::cin >> k;
    if(k%2 == 1){
        ans = ((k/2) + 1) * (k/2);
    }
    else {
        ans = (k/2) * (k/2);
    }
    std::cout << ans << std::endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://msdn.microsoft.com/library/3bstk3k5.aspx
//   http://www.cplusplus.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   http://www.boost.org/doc/


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD  998244353
#define REP(i,n) for(long long i = 0;i < n;++i)
int flowing[202][202] = {};
vector<int> goas[202];
int already_visited[202];
int solve(int now) {
	already_visited[now] = 1;
	if (now == 201) return 1;
	
	REP(tea,goas[now].size()){
		int q = goas[now][tea];
		if (now != q) {
			if (already_visited[q] == 0&&flowing[now][q] > 0) {
				int hoge =  solve(q);
				if (hoge == 1) {
					flowing[now][q] -= 1;
					flowing[q][now] += 1;
					return 1;
				}
			}
		}
	}
	return 0;
}
int main() {
	int h, w;
	cin >> h >> w;
	REP(i, h) {
		string s;
		cin >> s;
		REP(q, w) {
			if (s[q] != '.') {
				flowing[i + 1][101 + q] = 1;
				goas[i + 1].push_back(101 + q);
				flowing[101 + q][i + 1] = 1;
				goas[101 + q].push_back(i + 1);
				if (s[q] == 'S') {
					flowing[0][i + 1] = 100000;
					goas[0].push_back(i + 1);
					goas[0].push_back(101 + q);
					flowing[0][101 + q] = 100000;
					if (flowing[101 + q][201] != 0 || flowing[i + 1][201] != 0) {
						cout << -1 << endl;
						return 0;
					}
				}
				if (s[q] == 'T') {
					flowing[i + 1][201] = 100000;
					goas[i + 1].push_back(201);
					flowing[101 + q][201] = 100000;
					goas[101 + q].push_back(201);
					if (flowing[0][101 + q] != 0 || flowing[0][i + 1] != 0) {
						cout << -1 << endl;
						return 0;
					}
				}
			}
		}
	}
	int ans = 0;
	while (solve(0) != 0){
		REP(i, 202) {
			already_visited[i] = 0;
		}
	}
	REP(i, 202) {
		ans += flowing[201][i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import math

my_list = []
N, D = map(int, input().split())
for i in range(N):
    my_list.append(list(map(int, input().split())))
count = 0
for k in range(N-1):
	for i in range(k+1,N):
		sum = 0
		for j in range(D):
			sum =sum + ((int(my_list[i][j])-int(my_list[k][j]))**2)
		dist = math.sqrt(sum)
		if dist == int(dist):
			count = count+1
print (count)

Measured memory_bytes: 3064
#include <cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(){
	std::ios_base::sync_with_stdio(false);

	string inp,mozi;
	int kai;

	while(cin>>inp){
		for(int i=0;i<inp.length();i++){
			if(inp[i]=='@'){
				kai=inp[i+1]-'0';
				mozi=inp[i+2];
				for(int j=0;j<kai;j++){
					cout<<mozi;
				}
				i+=2;
			}
			else cout<<inp[i];
		}
		cout<<endl;
	}
		
	return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>

int main(){
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H){
        printf("Yes\n");
    }
    else printf("No\n");
}


Measured memory_bytes: 2124
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

int main(void) {
	int n;
	int h[101] = { 0 };
	int min;
	int ans = 0, left = 0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &h[i]);

	while (left != INT_MAX) {
		left = INT_MAX, min = INT_MAX;
		for (int i = 0; i <= n; i++) {
			if (h[i] != 0) {
				if (min == INT_MAX) left = i;
				if (min > h[i])min = h[i];
			}
			else if (i >= left) {
				for (int j = left; j < i; j++) h[j] -= min;
				ans += min;
				break;
			}
		}
		//printf("ans=%d\n", ans);
		//for (int k = 0; k < n; k++) printf("h[%d]=%d  ", k, h[k]);
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
if __name__ == '__main__':
  s = str(input())
  L = len(s)
  beg = -1
  end = -1
  for i in range(0,L):
    if s[i]=='A' and beg==-1:
      beg = i
    elif s[i]=='Z':
      end = i
  print(end-beg+1)


Measured memory_bytes: 3516
dp = [range(8) for i in range(1001)]

for i in range(1001) :
	for j in range(8) :
		dp[i][j] = 0

dp[0][1] = 1

n = input()
s = raw_input().strip()

for i in range(n) :
	b = 0
	if s[i] != 'J' :
		b += 1
		if s[i] != 'O' :
			b += 1
	
	for j in range(8) :
		for k in range(8) :
			if (((k >> b) & 1) and (j & k) != 0) :
				dp[i + 1][k] = (dp[i + 1][k] + dp[i][j]) % 10007

sum = 0
for i in range(8) :
	sum = (sum + dp[n][i]) % 10007

print sum

Measured memory_bytes: 4448
from random import randint
import sys
input = sys.stdin.readline
INF = 9223372036854775808


def calc_score(D, C, S, T):
    """
    開催日程Tを受け取ってそこまでのスコアを返す
    """
    score = 0
    last = [0]*26  # コンテストiを前回開催した日
    for d, t in enumerate(T, start=1):
        last[t-1] = d
        for i in range(26):
            score -= (d - last[i]) * C[i]
        score += S[d-1][t-1]
    return score


def update_score(D, C, S, T, score, ct, ci):
    """
    ct日目のコンテストをコンテストciに変更する
    スコアを差分更新する

    ct: change t 変更日 1-indexed
    ci: change i 変更コンテスト 1-indexed
    """
    last = [0]*26  # コンテストiを前回開催した日
    for d in range(1, ct):
        last[T[d-1]-1] = d
    prei = T[ct-1]  # 変更前に開催する予定だったコンテストi
    score -= S[ct-1][prei-1]
    score += S[ct-1][ci-1]
    for d in range(ct, D+1):
        if d != ct and T[d-1] == prei:
            break
        score += C[prei-1]*(d - ct)
        score -= C[prei-1]*(d - last[prei-1])
    for d in range(ct, D+1):
        if d != ct and T[d-1] == ci:
            break
        score += C[ci-1]*(d - last[ci-1])
        score -= C[ci-1]*(d - ct)
    T[ct-1] = ci
    return score, T


def local_search():
    pass


def main(D, C, S):
    T = []
    for d in range(D):
        # d日目終了時点で満足度が一番高くなるようなコンテストiを開催する
        max_score = -INF
        best_i = 1
        for i in range(26):
            T.append(i)
            score = calc_score(D, C, S, T)
            if max_score < score:
                max_score = score
                best_i = i
            T.pop()
        T.append(best_i)
    return T


if __name__ == '__main__':
    D = int(input())
    C = [int(i) for i in input().split()]
    S = [[int(i) for i in input().split()] for j in range(D)]
    T = [int(input()) for i in range(D)]
    M = int(input())
    DQ = [[int(i) for i in input().split()] for j in range(M)]
    score = calc_score(D, C, S, T)
    for d, q in DQ:
        score, T = update_score(D, C, S, T, score, d, q)
        print(score)


Measured memory_bytes: 97468
import java.util.Arrays;
import java.util.Scanner;

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

		int n = scan.nextInt();
		int m =scan.nextInt();

		int num[] = new int[n];
		 Arrays.fill(num, -1);
		 boolean r = true;

		for(int i = 0 ; i < m ; i++) {
			int s = scan.nextInt();
			int c = scan.nextInt();
			if(num[s-1] == -1 || num[s-1] == c) {
				num[s-1] = c;
			}else {
				r = false;
			}
		}

		if(r) {
			if(n == 1 && (num[0] == 0 || num[0] == -1)) {
				System.out.println(0);
			}else if(num[0] == 0) {
				System.out.println(-1);
			}else {
				System.out.print( num[0] == -1 ? 1 : num[0] );
				for(int i = 1 ; i < n ; i++) {
					if(num[i] == -1) {
						num[i] = 0;
					}
					System.out.print(num[i]);
				}
				System.out.println();
			}
		}else {
			System.out.println(-1);
		}

	}
}


Measured memory_bytes: 23636
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
   
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       int A = sc.nextInt();
       int B = sc.nextInt();
        
 
        System.out.println(A <=8 && B<= 8? "Yay!":":(");
        
    }
}

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

int main()
{
	int gakuban,ctr=0;;
	double tai,si;
	while(scanf("%d,%lf,%lf",&gakuban,&tai,&si) != EOF){
	//	scanf("%d,%f,%f",&gakuban,&tai,&si);
		double bmi = tai/(si*si);
		if(bmi >= 25){
			cout << gakuban << endl;
			++ctr;
		}
	}
	if(!ctr)	cout << "該当なし" << endl;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll A,B,K;
    cin>>A>>B>>K;
    for(int i=0;i<K;i++){
        B+=A/2;
        A/=2;
        i++;
        if(i==K) break;
        A+=B/2;
        B/=2;
    }
    
    cout<<A<<" "<<B<<endl;
    
    return 0;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N;
    int[][] a;

    private void solve() {
        N = nextInt();

        a = new int[2][N];
        for(int i = 0;i < 2;i++) {
            for(int j = 0;j < N;j++) {
                a[i][j] = nextInt();
            }
        }

        int max = 0;
        for(int i = 0;i < N;i++) {
            int candies = 0;

            for(int j = 0;j <= i;j++) {
                candies += a[0][j];
            }

            for(int j = i;j < N;j++) {
                candies += a[1][j];
            }

            max = Math.max(max,candies);
        }

        out.println(max);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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

Measured memory_bytes: 21332
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

struct data {
  long long sum;
  int x;
  int y;
  int z;
};


class CompareFirst {
public:
  bool operator()(data d1, data d2){
    return d1.sum<d2.sum;
  }
};

bool used[1001][1001][1001];

int main(){
  int X, Y, Z, K;
  scanf("%d", &X);
  scanf("%d", &Y);
  scanf("%d", &Z);
  scanf("%d", &K);
  std::vector<long long > A(X), B(Y), C(Z);
  for (int i=0; i<X; i++){
    scanf("%lld", &A[i]);
  }
  for (int i=0; i<Y; i++){
    scanf("%lld", &B[i]);
  }
  for (int i=0; i<Z; i++){
    scanf("%lld", &C[i]);
  }
  std::sort(A.begin(), A.end(), std::greater<long long>());
  std::sort(B.begin(), B.end(), std::greater<long long>());
  std::sort(C.begin(), C.end(), std::greater<long long>());
  
  int x=0;
  int y=0;
  int z=0;
  std::priority_queue<data, std::vector<data>, CompareFirst> queue;
  queue.push((data){A[0]+B[0]+C[0], 0, 0, 0});
  std::vector<long long >ans;
  used[0][0][0]=true;
  
  while(ans.size()<K){
    long long sum = queue.top().sum;
    int x = queue.top().x;
    int y = queue.top().y;
    int z = queue.top().z;
    queue.pop();
    ans.push_back(sum);
    if (x+1<X && !used[x+1][y][z]){
      queue.push((data){A[x+1]+B[y]+C[z], x+1, y, z});
      used[x+1][y][z]=true;
    }
    if (y+1<Y && !used[x][y+1][z]){
      queue.push((data){A[x]+B[y+1]+C[z], x, y+1, z});
      used[x][y+1][z]=true;
    }
    if (z+1<Z && !used[x][y][z+1]){
      queue.push((data){A[x]+B[y]+C[z+1], x, y, z+1});
      used[x][y][z+1]=true;
    }
  }
  for (int i=0; i<K; i++){
    printf("%lld\n", ans[i]);
  }
  return 0;
}
 

Measured memory_bytes: 8220
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)
N = _I()
B = LI()

"""
Bの値は、A, A+1の最大値
2 5 なら
A[1]は2でなくてはならない
? 2 ?
なんでも 2 5と決まる
2 2 5


3なら
3 3

5
 0 153 10 10 23なら
6
0 0 10 10 10 23

0 0 ? ? ? ?
0 0 10 10 ? ?
0 0 10 10 10 ?
0 0 10 10 10 23
最小値から決めていく
"""

A = [None] * N
#  print('a', A)
while any(a == None for a in A):
    min_idx = B.index(min(B))
    #  print(min_idx)
    if A[min_idx] is None:
        A[min_idx] = B[min_idx]
    if A[min_idx+1] is None:
        A[min_idx+1] = B[min_idx]
    B[min_idx] = inf

#  print(A)
print(sum(A))


Measured memory_bytes: 80236
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
int price[51];
vector<pair<int, int>> soba;
int dfs(int n){
	int mi = 10000;
	if (n == 0)return 0;
	REP(i, 6){
		if (n - soba[i].first == 0 || n - soba[i].first >= 200){
			if (price[(n - soba[i].first) / 100] == 10000)
				mi = min(mi, dfs(n - soba[i].first) + soba[i].second);
			else
				mi = min(mi, price[(n - soba[i].first) / 100] + soba[i].second);
		}
	}
	price[n / 100] = mi;
	return mi;
}
int main() {
	soba.push_back(pair<int, int>(200, 380));//1.9
	soba.push_back(pair<int, int>(300, 550));//18.3
	soba.push_back(pair<int, int>(500, 850));//1.7
	soba.push_back(pair<int, int>(1000, 1520));//1.52
	soba.push_back(pair<int, int>(1200, 1870));//1.55
	soba.push_back(pair<int, int>(1500, 2244));//1.496

	REP(i, 51){
		price[i] = 10000;
	}
	REP(i, 51){
		dfs(i * 100);
	}
	int n;
	while (cin >> n, n){
		cout << price[n / 100] << endl;
	}
}

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

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ld long double

int main()
{
	IOS;
	int n,a,b;
	cin >>n>>a>>b;
	if((n*a)<b)
	{
		cout <<n*a;
	}
	else
	{
		cout <<b;
	}
	cout <<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 

int main(void) {
  int m,d;cin>>m>>d;
  int ans = 0;
  for(int i = 20; i <= d; i++){
    if(i%10 <2) continue;
    if((i/10)*(i%10) <=m) ans++;
  }

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

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include <numeric>
#include<string>
using ll = long long;
using namespace std;
# define maxn 50
# define maxm 50

int main() {
  int n;
  vector <int>w;
  cin>>n;
  for (int i(0);i<n;i++){
    int wi;
    cin>>wi;
    w.push_back(wi);
  }
  int mini(10000000);
  for (int t(0);t<n;t++){
    int sum1(0),sum2(0);
    for (int i(0);i<n;i++){
      if (i<=t){
        sum1+=w[i];
      }else{
        sum2+=w[i];
      }
    }
    mini = min(mini,abs(sum1-sum2));
  }
  cout<<mini;
  return 0;
}


Measured memory_bytes: 256
from collections import deque

ans = deque()
center_ans_1 = input()
center_ans = list(center_ans_1)
for i in range(len(center_ans)):
    a = center_ans[i]
    ans.append(a)

q = int(input())
list_data = [ list(map(str,input().split(" "))) for i in range(q)]
#print(list_data)
re = 0
for i in range(q):
    list_a = list_data[i]
    #print(list_a)
    if list_a[0] == "1":
        re += 1
    elif list_a[0] == "2":
        if list_a[1] == "1":
            if re % 2 == 0:
                ans.appendleft(list_a[2])
            elif re % 2 == 1:
                ans.append(list_a[2])
        elif list_a[1] == "2":
            if re % 2 == 0:
                ans.append(list_a[2])
            elif re % 2 == 1:
                ans.appendleft(list_a[2])

if re % 2 == 1:
    ans.reverse()

print("".join(ans))


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

void AOJ0007()
{
	int N;
	cin >> N;
	long money = 100000;
	for (int i = 0; i < N; i++)
	{
		money *= 1.05;
		if (money % 1000 > 0)
		{
			money += (1000 - money % 1000);
		}
	}

	cout << money << endl;
}

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

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <utility>

using namespace std;

int main(){
	string s;
	cin >> s;
	pair<char, int> p[2];
	int i, j;

	p[0] = make_pair(s[0], 0);
	for (i = 1; i < 4; i++){
		if (s[0] != s[i])
			break;
	}
	p[1] = make_pair(s[i], 0);

	for (i = 0; i < 4; i++){
		for (j = 0; j < 2; j++){
			if (s[i] == p[j].first)
				p[j].second++;
		}
	}

	if (p[0].second == 2 && p[1].second == 2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <functional>
#include <ctime>
#include <queue>
#include <string>
#include <map>
#include <utility>
#include <sstream>
#include <cmath>
#define MAX_U   10
#define MIN_U   0
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define form(i,a,b) for(int i=(a);i<(b);i++)
#define sz(x) ((int)(x).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<char> vc;
typedef vector<string> vs;
typedef queue<int> qi;
const int INF=numeric_limits<int>::infinity();
void printa(){cout<<"\n";}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
void prints(){cout<<" ";}
template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
template<class... A>void prints(const A&... rest){prints(rest...);}
int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
double trapezium(int a,int b,int h){return (a+b)*h/2;}
double triangle(int a,int h){return a*h/2;}
void sorm(vector<int> vec){sort(vec.begin(),vec.end());}
void sorg(vector<int> vec){sort(vec.begin(),vec.end(),greater<int>());}
int cmp( const void *p, const void *q ) {if( *(double*)p > *(double*)q ) return 1;if( *(double*)p < *(double*)q ) return -1;return 0;}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    //vi ad,bd,cd,dd;
    //vs as,bs,cs,ds;
    cin>>a>>b>>c;
    if(a>b&&a>c){
        if(a-b>a-c)printa("B");
        else printa("A");        
    }
    else if(a<b&&a<c){
        if(b-a>c-a)printa("B");
        else printa("A");
    }
    else if(a>b&&a<c){
        if(a-b>c-a)printa("B");
        else printa("A");
    }
    else if(a<b&&a>c){
        if(b-a>a-c)printa("B");
        else printa("A");
    }
    return 0;
}

Measured memory_bytes: 256
//package atcoder;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		String s=sc.next();
		System.out.println(s.substring(0,k-1) + (char)(s.charAt(k-1)+32) + s.substring(k));

	}

}


Measured memory_bytes: 23764
#include<cstdio>
using namespace std;
int n,x,las,ans,c[200013];
int main(){
    scanf("%d",&n);
    ans=1;las=-1;
    for(register int i=0;i<n;++i){
        scanf("%d",&x);
        if(x==las)continue;
        las=x;
        ans=(1LL*ans+c[x])%1000000007;
        c[x]=ans;
    }
    printf("%d",ans);
    return 0;
}

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

int n;
int* h;
int* cost;
const int INF = 100000000;

int main(){
    cin >> n;
    h = new int[n];
    cost = new int[n];
    for(int i=0;i<n;i++){
        cin >> h[i];
        cost[i] = INF;
    }
    cost[0] = 0;
    cost[1] = abs(h[0] - h[1]);
    for(int i=2;i<n;i++){
        cost[i] = min(cost[i-2]+abs(h[i-2]-h[i]),cost[i-1]+abs(h[i-1]-h[i]));
    }
    cout << cost[n-1];
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());

            var ans = long.MaxValue;

            for (var i = 1L; i * i <= N ; i++)
            {
                if(N % i == 0)
                {
                    ans = Math.Min(Math.Max(i.ToString().Length, (N / i).ToString().Length), ans);
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27472