akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};

ll N;
llvec A;

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  cin >> N;
  A = llvec(N, 0);
  rep(i, N){
    cin >> A[i];
  }
  sort(rALL(A));
  ll cnt = 0;
  cnt++;
  ll ans = A[0];
  rep(i, N){
    if(cnt == N - 1)break;
    ans += A[i/2+1];
    cnt++;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 4820
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;

public class Main {

	static ArrayList<Integer> alredy = new ArrayList<>();
	static Deque<Integer> stack = new ArrayDeque<>();
	static ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();

	static int count = 0;
	static int n;

	static boolean flag = false;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<>());
		}

		for (int i = 0; i < m; i++) {
			str = br.readLine().split(" ");
			int a = Integer.parseInt(str[0]);
			int b = Integer.parseInt(str[1]);
			list.get(a - 1).add(b - 1);
		}
		dfs(0);
		if (flag) {
			System.out.println("POSSIBLE");
		} else {
			System.out.println("IMPOSSIBLE");
		}
	}

	static void dfs(int a) {
		stack.add(a);
		count++;
		while (!stack.isEmpty()) {
			int next = stack.poll();
			alredy.add(next);
			for (int i = 0; i < list.get(next).size(); i++) {
				int b = list.get(next).get(i);
				if (count <= 2) {
					if (b == n - 1) {
						flag = true;
						break;
					} else {
						dfs(b);
					}
				}
			}
			count = 0;
		}
	}
}

Measured memory_bytes: 71792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ld long double
#define mod 998244353
int main()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
        ans+=min(a,k);
        k-=min(a,k);
       k-=min(b,k);
       ans-=min(c,k);
       cout<<ans;

}


Measured memory_bytes: 3592
import sys
sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, Q, ABs, PXs):
    tree_map = [[] for _ in range(N + 1)]
    for a, b in ABs:
        tree_map[a].append(b)
        tree_map[b].append(a)

    ans = [0 for _ in range(N + 1)]
    for p, x in PXs:
        ans[p] += x

    def dfs(v, r):  # vertex, root
        ans[v] += ans[r]
        for tm in tree_map[v]:
            if tm == r:
                continue
            dfs(tm, v)

    dfs(1, 0)

    for a in ans[1:]:
        print(a)


if __name__ == '__main__':
    N, Q = map(int, input().split())
    ABs = [[int(i) for i in input().split()] for _ in range(N - 1)]
    PXs = [[int(i) for i in input().split()] for _ in range(Q)]
    solve(N, Q, ABs, PXs)


Measured memory_bytes: 332332
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b;std::cin >> a >> b;
  std::cout << (a<=b?"unsafe":"safe") << '\n';
  return 0;
}


Measured memory_bytes: 3132
#!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    M,T,P,R = map(int,input().split(" "))
    if M == 0 and T == 0 and P == 0 and R == 0:
        break
    #no, correct, wrong, time
    teams = [[j,0,[0 for i in range(P+1)],0] for j in range(T+1)]

    for i in range(R):
        m,t,p,j = map(int,input().split(" "))
        if j == 0:
            if teams[t][2][p] != -1:
                teams[t][1] += 1
                teams[t][3] += teams[t][2][p] * 20 + m
                teams[t][2][p] = -1
        else:
            teams[t][2][p] += 1
    prev = None
    for t in sorted(teams[1:],key=lambda t:(t[1],-t[3],t[0]),reverse=True):
        if prev is not None:
            if prev[1] == t[1] and prev[3] == t[3]:
                print('=',end="")
            else:
                print(',',end="")
        print(t[0],end="")
        prev = t
    print()

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

typedef long long lli;

lli a,b,c,d;

int main(){
  cin >> a >> b >> c >> d;
  if(a+b > c+d) cout << "Left" << endl;
  else if(a+b < c+d) cout << "Right" << endl;
  else cout << "Balanced" << endl;
  return 0;
}

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

int main(void)
{
    char s[100], p[100], add[200];
    
    scanf("%s", &s);
    scanf("%s", &p);

    strcpy(add, s);
    strcat(add, s);

    printf(strstr(add, p) != NULL ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 548
import math
import sys
#mod = 998244353
#sys.setrecursionlimit(100000)


il = []
for line in sys.stdin:
    il.append(line.strip())

N = int(il[0])
il = il [1:]

def main():
    if N != len(set(il)):
        print("No")
        return
    temp_w = None
    for w in il:
        if temp_w != None:
            if temp_w[-1] != w[0]:
                print("No")
                return
        temp_w = w
    print("Yes")
main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) ll((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
const ll MOD = 1E9+7;
const ll INF = 1E18;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

const int N=1<<17;
bool used[N];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int m,k;
	cin>>m>>k;
	if((m==1&&k==1)||k>=(1<<m)) exit(puts("-1\n")*0);
	if(!k){
		REP(i,1<<m)
			cout<<i<<' '<<i<<' ';
		cout<<'\n';
		return 0;
	}
	deque<int> res;
	res.pb(k);
	REP(i,1<<m)
		if(i!=k)
			res.push_front(i),res.pb(i);
	res.pb(k);
	for(int x:res) cout<<x<<' ';
	cout<<'\n';
}



Measured memory_bytes: 4692
#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x << endl
#define De(...)
using namespace std; 

int _; 

int l,r,d;
 
int main()
{
	//for(scanf("%d",&_);_;_--)
	scanf("%d%d%d",&l,&r,&d);
	printf("%d\n",r/d-(l-1)/d);
	return 0;
}


Measured memory_bytes: 3824
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

double dist(int a, int b, int c, int d){
 	return sqrt( (a-b) * (a-b) + (c-d) * (c-d) ); 
}

int main(void){
	int N;
	cin >> N;
	int *x, *y;
	x = new int[N];
	y = new int[N];
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
	}
	
	double distance = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			distance += dist(x[i],x[j],y[i],y[j]);
        }
	}
	
	cout << fixed << setprecision(10) << 2*distance/N << endl;

	delete[] x;
	delete[] y;
	return 0;
}





Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    string s;
    cin >> s;
    bool ans = true;
    if(s[0] != 'A'){
        ans = false;
    }
    int cnt = 0;
    REP(i, 2, s.size() - 1){
        if(s[i] == 'C'){
            cnt++;
        }
    }
    if(cnt != 1){
        ans = false;
    }
    cnt = 0;
    if(ans){
        rep(i, s.size()){
            if('a' <= s[i] && s[i] <= 'z'){
                cnt++;
            }
        }
        if(cnt != s.size() - 2){
            ans = false;
        }
    }
    if(ans){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

using ll = long long;
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
int main(){
    int N;
    cin >> N;
    int h[N];
    rep(i, N)cin >> h[i];
    int ans = 1;
    int high = h[0];
    loop(i, 1, N){
        if(h[i] >= high) ans++;
        high = max(high, h[i]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int n, ta, tb;
vector< int > x[100005];

int dfs(int a, int b) {
	int re = 0;
	for (int i = 0; i < x[a].size(); i++)
		if (x[a][i] != b)
			re ^= dfs(x[a][i], a) + 1;
	return re;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d%d", &ta, &tb);
		x[ta].push_back(tb);
		x[tb].push_back(ta);
	}
	printf(dfs(1, 0) ? "Alice\n" : "Bob\n");
	return 0;
}

Measured memory_bytes: 11904
#include<iostream>
using namespace std;
int kaku_keta_wa(int N);

int main(void) {
	int N; cin >> N;
	int a = kaku_keta_wa(N);

	if (N%a == 0) {
		cout << "Yes" << endl;
	}
	else { cout << "No" << endl; }

	return 0;
}

int kaku_keta_wa(int N) {
	int M, sum = 0;
	while (N) {
		M = N % 10;
		sum = sum + M;
		N = N / 10;
	}
	return sum;
}


Measured memory_bytes: 256
while line = gets
	n, x = line.split( " " ).map { | val | val.to_i }
	break if 0 == n && 0 == x

	cnt = 0
	for i in ( 1 .. n-2 )
		for j in ( i+1 .. n-1 )
			for k in ( j+1 .. n )
				s = ( i + j + k )
				if x == s
					cnt += 1
					break
				end
			end
		end
	end
	
	puts( cnt )
end

Measured memory_bytes: 6108
#include <stdio.h>

int main(void){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(a+b==c+d)
    puts("Balanced");
  else if(a+b>c+d)
    puts("Left");
  else
    puts("Right");
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
int n;
bool used[MAXN];
int main(){
    SF("%d",&n);
    if(n==3){
        PF("2 5 63");
        return 0;
    }
    used[2]=1,used[4]=1,used[3]=1,used[9]=1;
    n-=4;
    int x=8,y=10;
    while(n>1&&y<=30000){
        used[x]=1;
        used[y]=1;
        n-=2;
        x+=6;
        y+=6;
    }
    x=15,y=21;
    while(n>1&&y<=30000){
        used[x]=1;
        used[y]=1;
        n-=2;
        x+=12;
        y+=12;
    }
    x=6;
    while(n>0&&x<=30000){
        used[x]=1;
        x+=6;
        n--;
    }
    for(int i=2;i<=30000;i++)
        if(used[i]==1)
            PF("%d ",i);
} 

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int K;
    string S;
    cin >> K >> S;
    string ans = "";
    if(S.length()>K){
        for (int i = 0; i < K; i++)
        {
            ans += S[i];
        }
        ans += "...";
    }else{
        ans = S;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define Int long long
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  int N, K; cin >> N >> K;
  vector<int> l(N);
  rep(i,N) cin >> l[i];
  sort(l.begin(), l.end(), greater<int>());
  int ans = 0;
  rep(i, K) ans += l[i];
  cout << ans << endl;
}


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

#define o(output) cout << output << endl

using namespace std;

string s;
int a,b,c,d;
char A,B;
priority_queue<int> pr;
vector<int> vec;

int main(){
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b;
    vec.push_back(b);
    } 
  sort(vec.begin(),vec.end());
  o(vec[a-1]-vec[0]);
}

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

using namespace std;

int main()
{
  while (true)
  {
    int H, W;
    cin >> H >> W;
    if (!H)
      return 0;

    for (int i = 1; i <= H; i++)
    {
      for (int j = 1; j <= W; j++)
      {
        if (i == 1 || i == H || j == 1 || j == W)
          cout << "#";
        else
          cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
}

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


#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int N = 2e5 + 10;

int ans;

using namespace std;

int main()
{

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  IOS;


  
  int n,k;

  cin>>n>>k;

  int a[n];

  loop(i,n)
  {
    cin>>a[i];
  }

  sort(a,a+n);

  int sum=0;

  for(int i=0; i<k; i++)
  {
    sum += a[i];
  }

  cout<<sum<<endl;
  
}


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

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

int search(int n,double sqrt_p,double (*f)(double)){
  int i=1,j,r=0,s=0;
  double gosa=10000,x,g;
  for(;i<=n;i++){
    if((j=(int)f(sqrt_p*i))>n)break;
    g=(x=(double)j/i-sqrt_p)*x;
    if(g<gosa&&gcd(j,i)==1){gosa=g;r=j;s=i;}
  }
  return r*20000+s;
}

int main(){
  int n,p,x,y;
  double sqrt_p;
  while(scanf("%d%d",&p,&n),p){
    sqrt_p=sqrt(p);
    x=search(n,sqrt_p,floor);
    y=search(n,sqrt_p,ceil);
    printf("%d/%d %d/%d\n",y/20000,y%20000,x/20000,x%20000);
  }
  return 0;
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int a,b,c;
  cin>>a>>b>>c;

  cout<<a*b/2<<endl;


return 0;}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	vector<long long>a,b;
	cin>>n;
	a.resize(n);
	b.resize(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[i]=a[i]-i-1;
	}
	sort(b.begin(),b.end());
	long long c=b[n/2],ans=0;
	for(int i=0;i<n;i++)ans+=abs(b[i]-c);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n, h;
    cin >> n >> h;
    ll a[n], b[n];
    ll mxa = -1;
    rep(i, 0, n) {
        cin >> a[i] >> b[i];
        mxa = max(mxa, a[i]);
    }

    sort(b, b + n, greater<ll>());
    ll sum = 0;
    ll ans = 0;
    rep(i, 0, n) {
        if (b[i] >= mxa) {
            sum += b[i];
            ans++;
            if (sum >= h) {
                cout << ans << endl;
                return 0;
            }
        }
    }

    ll numovermxa = 0;
    ll sumovermxa = 0;
    rep(i, 0, n) {
        if (b[i] >= mxa) {
            numovermxa++;
            sumovermxa += b[i];
        }
    }

    cout << (h - sumovermxa + mxa - 1) / mxa + numovermxa << endl;
    return 0;
}


Measured memory_bytes: 1792
def sol(a):
    if len(set(a))==1:
        tmp=a.pop()
        if tmp=='s':
            return ''
        else:
            return tmp
    else:
        return ''
while 1:
    try:
        n=raw_input()
        f=1 
        for i in range(0,7,3):
            if sol(list(n[i:i+3])):
                print sol(list(n[i:i+3]))
                f=0
        for i in range(3):
            if sol(list(n[i]+n[i+3]+n[i+6])):
                print sol(list(n[i]+n[i+3]+n[i+6]))
                f=0
        if f and (sol(list(n[0]+n[4]+n[8])) or sol(list(n[2]+n[4]+n[6]))):
            print sol(list(n[0]+n[4]+n[8]))+sol(list(n[2]+n[4]+n[6]))
            f=0
        if f:
            print 'd'

    except:
        break

Measured memory_bytes: 6480
n, a = map(int,input().split( ))

x = list(map(int,input().split( )))

for i in range(n):
    x[i] -= a

mx = 0
for i in range(n):
    mx += abs(x[i])
mx +=1

dp = [[0 for i in range(3*mx)] for j in range(n)]
dp[0][0] += 1
dp[0][x[0]] += 1

for i in range(1,n) :
    for j in range(-mx,mx):
        dp[i][j] += dp[i-1][j-x[i]]
        dp[i][j] += dp[i-1][j]
    #print(*dp[i])
print(dp[n-1][0]-1)


Measured memory_bytes: 43740
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cmath>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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


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

    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    
    vector<int> x(N);
    vector<int> y(M);

    for(int i = 0; i < N; i++) cin >> x[i];
    for(int i = 0; i < M; i++) cin >> y[i];

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    if( X < y[0] && x[N-1] < Y && x[N-1] < y[0]){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
A,B,K=map(int,input().rstrip().split())
 
"""
def resolve():
    if(A>K):
        ansA=int(A)-int(K)
        ansB=int(B)
    else:
        ansA=0
        ansB=int(B)-(int(K)-int(A))
        if(ansB<0):
            ansB=0
    print(str(int(ansA))+" "+str(int(ansB)))
"""

def resolve():
    if(A>K):
        ansA=int(A)-int(K)
        ansB=int(B)
    else:
        ansA=0
        ansB=int(B)-(int(K)-int(A))
        if(ansB<0):
            ansB=0
    print(ansA,ansB)


import sys
from io import StringIO
import unittest
#1000000000000 1000000000000 1000000000001
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 3 3"""
        output = """0 2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """500000000000 500000000000 1000000000000"""
        output = """0 0"""
        self.assertIO(input, output)
 
if __name__ == "__main__":
    #unittest.main()
    resolve()

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

using namespace std;

string thi[100],tha[100],the[100];

string change_str(string ch,int mov);
int set(void);

int main()
{
	int i,j;
	char ch[100];
	
	set();
	for(;cin.getline(ch,81);)
	{
		for(i=0;i<27;i++)
		{
			int se;
			se=string(ch).find(thi[i],0);
			if(se!=string::npos)
				break;
			se=string(ch).find(tha[i],0);
			if(se!=string::npos)
				break;
			se=string(ch).find(the[i],0);
			if(se!=string::npos)
				break;
		}
		
		string ans;
		
		ans=change_str(string(ch),26-i);
		
		cout << ans << endl;
		
		string(ch)="";
	}
}

int set(void)
{
	int i,j;
	thi[0]="this";
	tha[0]="that";
	the[0]="the";
	
	for(i=1;i<27;i++)
	{
		int a,b,c;
		thi[0]=change_str(thi[0],1);
		tha[0]=change_str(tha[0],1);
		the[0]=change_str(the[0],1);
		
		thi[i]=thi[0];
		tha[i]=tha[0];
		the[i]=the[0];
	}
	return 0;
}

string change_str(string change,int mov)
{
	for(int i=0;i<mov;i++)
	{
		for(int j=0;j<change.size();j++)
		{
			int a;
			a=int(change[j]);
			if(a>95 && a<123)
			{
				change[j]++;
				if(a==122)
					change[j]-=26;
			}
		}
	}
	return change;
}

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

int main() {
  int x,a,b;
  cin>>x>>a>>b;

  char ans;
  if (abs(x-a)<abs(x-b)) ans='A';
  else ans='B';
  cout<<ans<<endl;
  return 0;
}

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

int calc(int a,int c){
    int i;
    //printf("%d %d\n",a,c);
    for(i=1;i<c;i++){
        a*=10;
    }
    //printf("%d\n",a);
    return a;
}

int main(int argc, const char * argv[]) {
    int i,n,j,k,swap,l,max=0,min=0;
    char in[9],inmax[9],inmin[9];
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",in);
        strcpy(inmax,in);
        strcpy(inmin,in);
        for(j=0;j<8;j++){
            for(k=j+1;k<8;k++){
                if(inmax[j]<inmax[k]){
                    swap=inmax[j];
                    inmax[j]=inmax[k];
                    inmax[k]=swap;
                }
                if(inmin[j]>inmin[k]){
                    swap=inmin[j];
                    inmin[j]=inmin[k];
                    inmin[k]=swap;
                }
            }
        }
        
        for(l=0;l<8;l++){
            max+=calc(inmax[l]-'0',8-l);
            min+=calc(inmin[l]-'0',8-l);
        }
        //printf("%d\n",max);
        //printf("%d\n",min);
        printf("%d\n",max-min);
        max=0;
        min=0;
    }
    return 0;
}

Measured memory_bytes: 1804
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();

        if (a == 1 || b == 1) {
            System.out.println(1);

        } else {
            int result = getSqrtCount(getGcd(a, b));
            System.out.println(result + 1);
        }
    }

    public static long getGcd(long a, long b) {
        long temp;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return b;
    }

    public static int getSqrtCount(double n) {
        HashSet<Integer> list = new HashSet<>();
        for (int i = 2; i < Math.sqrt((double) n) + 2; i++) {
            while (n % i == 0) {
                n /= i;
                list.add(i);
            }
        }
        if (n > 1) {
            list.add((int)n);
        }
        return list.size();
    }
}

Measured memory_bytes: 23892
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        // 人々の座標
        int n;
        n = sc.nextInt();
        ArrayList<Integer> persons = new ArrayList<>();
 
        for (int i = 0; i < n; i++) {
            persons.add(sc.nextInt());
        }
 
        int target = 0;
        // 点Pの算出
        int min = 100;
        int max = 0;
 
        // min
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) <= min) {
                min = persons.get(i);
            }
        }
 
        // max
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) >= max) {
                max = persons.get(i);
            }
        }
 
        int targetMin = 0;
        // 点Pと各座標の算出
        for (int tenP = min; tenP < max; tenP++) {
        	target =0;
            for (int i = 0; i < persons.size(); i++) {
                target = target + (persons.get(i) - tenP) * (persons.get(i) - tenP);
            }
            if(tenP == min) {
              targetMin = target;
            }else if(targetMin > target) {
            	targetMin = target;
            }
        }
 
        System.out.println(targetMin);
    }
}

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



int main() {
    ll H;
    cin>>H;
    ll num=1,hp=H,ans=0;
    while(hp>1){
        hp/=2;
        ans+=num;
        num*=2;
    }
    ans+=num;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



struct Point{
	Point(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}

	Point(){
		x = y = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y);}
	Point operator * (double a){ return Point(a*x,a*y); }
	Point operator / (double a){ return Point(x/a,y/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y; }

	bool operator<(const Point &p) const{
		return x != p.x? x < p.x: y < p.y;
	}

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
	}

	double x,y;
};
typedef Point Vector;

struct Circle{
	Point center;
	double r;
};

int N,K;
Point point[65];
double C[65];
Circle circle[65];


double arg(Vector p){
	return atan2(p.y,p.x);
}

Vector polar(double a,double r){
	return Point(cos(r)*a,sin(r)*a);
}

double norm(Vector a){
	return a.x*a.x+a.y*a.y;
}

double abs(Vector a){
	return sqrt(norm(a));
}

vector<Point> getCrossPoints(Circle c1,Circle c2){

	vector<Point> res;

	double d = abs(c1.center-c2.center);
	double a = acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
	double t = arg(c2.center-c1.center);

	res.push_back(Point(c1.center+polar(c1.r,t+a)));
	res.push_back(Point(c1.center+polar(c1.r,t-a)));

	return res;
}

double calc_dist(Point A,Point B){

	return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}


//2つの円が2点で交わるか否か
bool is_Cross(Circle A,Circle B){

	double tmp_dist = calc_dist(A.center,B.center);

	return tmp_dist+EPS < A.r+B.r;
}

bool isOK(double len){


	vector<Point> V;

	for(int i = 0; i < N; i++){
		circle[i].center = point[i];
		circle[i].r = len/C[i];

		V.push_back(point[i]);
	}

	for(int i = 0; i < N-1; i++){
		for(int k = i+1; k < N; k++){
			if(!is_Cross(circle[i],circle[k]))continue;

			vector<Point> tmp =  getCrossPoints(circle[i],circle[k]);
			V.push_back(tmp[0]);
			V.push_back(tmp[1]);
		}
	}

	int count;

	for(int i = 0; i < V.size(); i++){

		count = 0;

		for(int k = 0; k < N; k++){
			if(calc_dist(circle[k].center,V[i]) <= circle[k].r+EPS){

				count++;
			}
		}
		if(count >= K)return true;
	}

	return false;
}


int main(){

	scanf("%d %d",&N,&K);

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

		scanf("%lf %lf %lf",&point[i].x,&point[i].y,&C[i]);
	}

	double left = 0,right = 1000000,mid = (left+right)/2;
	double ans = 1000000;

	while(left+EPS < right){

		if(isOK(mid)){

			ans = mid;
			right = mid-EPS;
		}else{

			left = mid+EPS;
		}
		mid = (left+right)/2;
	}

	printf("%.10lf\n",ans);

	return 0;
}


Measured memory_bytes: 512
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

use std::cmp::Ordering;

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
struct Rev(usize);

impl Ord for Rev {
    fn cmp(&self, other: &Rev) -> Ordering {
        other.0.cmp(&self.0)
    }
}

impl PartialOrd for Rev {
    fn partial_cmp(&self, other: &Rev) -> Option<Ordering> {
        Some(other.0.cmp(&self.0))
    }
}


#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      m: usize,
      abcs: [(usize1,usize1,usize); m],
    }

    const INF: usize = 1 << 50;
    let mut dist = vec![vec![INF; n]; n];
    for &(a, b, c) in abcs.iter() {
        dist[a][b] = c;
        dist[b][a] = c;
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
            }
        }
    }

    let mut ans = 0;
    for &(a, b, c) in abcs.iter() {
        if dist[a][b] == c {
            ans += 1;
        }
    }
    puts!("{}\n", m-ans);
}


Measured memory_bytes: 4352
// F.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL t1 = -1, t2, a1, a2, b1, b2;
		cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
		if (t1 < 0) return 0;
		LL p = (a1 - b1) * t1, q = (a2 - b2) * t2;
		if (p < 0) {
			p = -p, q = -q;
		}
		if (p + q == 0) {
			cout << "infinity" << endl;
		} else {
			LL ans = 0;
			if (p + q < 0) {
				LL r = p / -(p + q), s = p % -(p + q);
				ans = r * 2 + (s != 0);
			}
			cout << ans << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s;
  ll t = sqrt(s);

  if(t * t == s) {
    cout << "0 0 0 " << t << " " << t << " 0" << endl;
  } else {
    t += 1;
    ll e = (t * t) - s;
    cout << "0 0 1 " << t << " " << t << " " << e << endl;
  }
}


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

string s;

int main() {
	int cnt;
	cin>>s;
	for (int i=0;i<=s.size()-1;i++) {
		if (s[i]=='2') {
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;	
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readNextInt() int{
  sc.Scan()
  n,_ := strconv.Atoi(sc.Text())
  return n
}

func gcd(a int, b int) int {
  if b > a {
    tmp := a
    a = b
    b = tmp
  }

  for b > 0 {
    r := a%b
    a = b
    b = r
  }

  return a
}

func main() {
  sc.Split(bufio.ScanWords)
  a := readNextInt()
  b := readNextInt()

  output := gcd(a,b)
  fmt.Println(strconv.Itoa(output))
}


Measured memory_bytes: 1120
#include <stdio.h>
#include <string.h>
 
int main(void){
 
  char taro[100],hanako[100];
  int n;
  int t_point = 0;
  int h_point = 0;
  register int i,j;
 
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%s %s",taro,hanako);
    j = 0;
    if(strcmp(taro,hanako) == 0){
      t_point++;
      h_point++;
      continue;
    }
    while((taro[j] != '\0') || (hanako[j] != '\0')){
      if(taro[j] < hanako[j]){
        h_point += 3;
        break;
      }else if(taro[j] > hanako[j]){
        t_point += 3;
        break;
      }
      j++;
    }
  }
  printf("%d %d\n",t_point,h_point);
  return 0;
}

Measured memory_bytes: 604
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=20010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,T,res,gg;
signed main()
{
    n=read(), T=read();
    for(ri int i=1;i<=n;i++)
    {
        int x=read();
        res+=x+T;
        res-=max(gg,x);
        gg=x+T;
    }
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 3736
#include<iostream>

using namespace std;

int main(){
    long long int n;
    long long int sum=0;
    cin >> n;
    for (int i=0; i<=n; i++){
        if ( i % 3 != 0 && i % 5 != 0) sum += i;
    }

    //sum = (n+1) * n / 2 + (n/15+1) * n / 2 - (n/3+1) * n / 2 - (n/5+1) * n / 2;
    //printf("%16lu", sum);
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3620
n, y = gets.split.map(&:to_i)

max_10000 = [y / 10000, n].min

answer = [-1, -1, -1]

(0..max_10000).each do |n_10000|
  remain = y - 10000 * n_10000
  max_5000 = [remain / 5000, n - n_10000].min

  (0..max_5000).each do |n_5000|
    n_1000 = n - (n_10000 + n_5000)
    if n_10000 * 10000 + n_5000 * 5000 + n_1000 * 1000 == y
      answer = [n_10000, n_5000, n_1000]
    end
  end
end

puts answer.join(' ')


Measured memory_bytes: 1788
#include <iostream>
#include <queue>
#include <climits>
using namespace std;
typedef unsigned long long int ll;
#define INFI LLONG_MAX
int main(){
	ll t=1;
	//cin>>t; 

	while(t--){
ll h;
ll n;
cin>>h;
cin>>n;
ll ar[n];
ll sum=0;
for(int i=0;i<n;i++)
{
	cin>>ar[i];
	sum+=ar[i];
}
if(sum>=h)  cout<<"Yes";
else cout<<"No";

}
}






   
    


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

int main() {
  int N, sum;
  cin >> N;
  
  for(int i=0; i<N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    long long int a,b,n;
    scanf("%lld %lld %lld",&a,&b,&n);
    if(b==n)
    {
        printf("%lld",(a*(n-1))/b-(a*((n-1)/b)));
    }
    else if(b>n)
    {
        printf("%lld",(a*n)/b-(a*(n/b)));
    }
    else
    {
        long long int range=((n/b)*b)+b-1;
        if(range>n)
        range=((n/b)-1)*b+b-1;
        printf("%lld",(a*range)/b-(a*(range/b)));
    }
}

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

using namespace std;

signed main()
{
	//freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int a[n];
	map<int, int> lol;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		lol[a[i]]++;
		lol[a[i] - 1]++;
		lol[a[i] + 1]++;
	}
	int ans = 0;
	for(auto it: lol)
		ans = max(ans, it.second);
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StackControler readDataArr = new StackControler(in.readLine()
				.split(" "));
		System.out.println(readDataArr.calcData());
	}
}

class Stack {
	private int[] stack;
	private static int pointer = 0, popData, remover = 0;

	Stack(int[] stack) {
		this.stack = stack;
	}

	public void push(int data) {
		stack[pointer] = data;
		pointer++;
	}

	public int pop() {
		pointer--;
		popData = stack[pointer];
		stack[pointer] = remover;// pop????????????data?????????
		return popData;
	}

}

class StackControler {
	private Stack stack;
	private String[] readData;
	private int operand2, operand1, result, strToIntData;

	StackControler(String[] readData) {
		this.readData = readData;
	}

	public int calcData() {
		String tempStrData;
		stack = new Stack(new int[readData.length / 2 + 1]);
		for (int i = 0; i < readData.length; i++) {
			tempStrData = readData[i];

			if (tempStrData.equals("+")) {
				operand1 = stack.pop();
				operand2 = stack.pop();
				result = operand2 + operand1;
				stack.push(result);
			} else if (tempStrData.equals("-")) {
				operand1 = stack.pop();
				operand2 = stack.pop();
				result = operand2 - operand1;
				stack.push(result);
			} else if (tempStrData.equals("*")) {
				operand1 = stack.pop();
				operand2 = stack.pop();
				result = operand2 * operand1;
				stack.push(result);
			} else {
				strToIntData = Integer.parseInt(readData[i]);
				stack.push(strToIntData);
			}
		}
		result = stack.pop();
		return result;
	}
}

Measured memory_bytes: 24392
from collections import deque


def main():
    N = int(input())
    s = deque()
    H = [int(h) for h in input().split()]

    s = deque()
    h0 = 0
    count = 0
    for h in H:
        if s and s[-1] > h:
            count += (s[-1] - h)
            while s and s[-1] > h:
                s.pop()
        s.append(h)
    count += s[-1]
    print(count)


main()


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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void){
    long long A,ans,B_;
    long double B;

    cin>>A>>B;

    B_=B*100+0.5;
    ans=(A*B_)/100;
   

    // cout<<ans<<endl;
    printf("%lld\n",ans);


    return 0;
}



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

using namespace std;

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

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

int x[25],y[25],r[25],c[25];

bool in(int i, int j){
    int dist = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
    int d = (r[i] + r[j]) * (r[i] + r[j]);
    return dist < d;
}

int b[25]; // 上に重なっている円盤の番号(bit)
char dp[1 << 24];//i-bitが立っている = 円盤iは消えている


int main(void) {
    int i,j,k;
    int n;
    while(cin>>n, n){
        rep(i,n){
            cin >> x[i] >> y[i] >> r[i] >> c[i];
            b[i] = 0;
            rep(j,i)if(in(i,j)) b[i] |= (1<<j);
        }

        int ans = 0;
        int m = (1 << n);
        rep(i,m)dp[i] = -1;
        dp[0] = 0;

        rep(i,m){
            if(dp[i] < 0) continue;
            ans = max(ans, (int)dp[i]);

            //残っている円盤の状態がiのときに消せる円盤のペア(j,k)を探す
            rep(j,n){
                if(i & (1 << j))continue; //すでに円盤jが消えている
                if((i & b[j]) != b[j]) continue; //円盤j上の円盤(b[j])のどれかがまだ残っている

                loop(k,j+1,n)if(c[j] == c[k]){
                    if(i & (1 << k))continue; //すでに円盤kが消えている
                    if((i & b[k]) != b[k]) continue; //円盤k上の円盤(b[k])のどれかがまだ残っている

                    int next = i | (1 << j) | (1 << k); //円盤jと円盤kを消した状態
                    dp[next] = max((int)dp[next], dp[i] + 2);
                }

            }

        }

        cout << ans << endl;

    }
}



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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<double> P(N);
  for (auto &p : P) {
    cin >> p;
  }
  vector<vector<double>> dp(N + 5, vector<double>(N + 5));
  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= N; j++) {
      dp[i + 1][j] = dp[i][j] * (1 - P[i]);
      if (j > 0) {
        dp[i + 1][j] += dp[i][j - 1] * P[i];
      }
    }
  }
  double ans = 0;
  for (int i = 0; i < (N + 1) / 2; i++) {
    ans += dp[N][N - i];
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 70912
#include<cstdio>
#include<cmath>
#define ri register int
#define rc register char
#define ll long long int
#define rl register long long int
#define in inline
#define gc getchar
in ll read()
{
	rl x=0,p=1;
	rc ch=gc();
	while(ch<'0' || ch>'9')
	{
		if(ch=='-')
		{
			p=-1;
		}
		ch=gc();
	}
	while(ch>='0' && ch<='9')
	{
		x=x*10+ch-'0',ch=gc();
	}
	return x*p;
}
ll a,b,c;
int main()
{
	a=read(),b=read(),c=read();
	if(a+b>=c)
	{
		puts("No");
	}
	else
	{
		ll d=(c-a-b)*(c-a-b);
		if(4*a*b<d)
		{
			puts("Yes");
		}
		else
		{
			puts("No");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int N,ans=0;
    string S;
    cin >> N >> S;

    char num[3];
    REP(i,0,1000){
        num[0]='0'+i/100;
        num[1]='0'+i%100/10;
        num[2]='0'+i%10;
        int step=0;
        REP(j,0,S.size()){
            if(num[step]==S[j]) step++;
        }
        if(step>=3){
            ans++;
        }
    }
    P(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>
#include <utility>
#include <cstdlib>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

struct Coordinate{
    uint x;
    uint y;
    explicit Coordinate(uint x, uint y): x(x), y(y){};
    uint operator - (const Coordinate c){
        return (uint)(abs((int)x-(int)c.x) + abs((int)y-(int)c.y));
    };
};

int main() {
    uint H, W, D;
    cin >> H >> W >> D;
    vector<vector<uint>> As(H, vector<uint>(W, 0));
    for (auto &&i: irange(0U, H)){
        for (auto &&j: irange(0U, W)){
            uint written_value;
            cin >> written_value;
            As.at(i).at(j) = written_value - 1;
        }
    }
    uint Q;
    cin >> Q;
    vector<uint> Ls(Q, 0);
    vector<uint> Rs(Q, 0);
    for (auto &&i: irange(0U, Q)){
        uint written_value_l, written_value_r;
        cin >> written_value_l >> written_value_r;
        Ls.at(i) = written_value_l - 1;
        Rs.at(i) = written_value_r - 1;
    }

    vector<Coordinate> reverse_dict(H*W, Coordinate(numeric_limits<uint>::max(), numeric_limits<uint>::max()));
    for (auto &&i: irange(0U, H)){
        for (auto &&j: irange(0U, W)){
            reverse_dict.at(As.at(i).at(j)).x = j;
            reverse_dict.at(As.at(i).at(j)).y = i;
        }
    }
    vector<uint> accumulated_costs(H*W, numeric_limits<uint>::max());
    for (auto &&init_value: irange(0U, D)){
        for (unsigned int j = init_value; j < H*W; j+=D) {
            if (j < D){
                accumulated_costs.at(j) = 0;
            } else {
                accumulated_costs.at(j) = accumulated_costs.at(j-D) + (reverse_dict.at(j)-reverse_dict.at(j-D));
            }
        }
    }
    for (auto &&i: irange(0U, Q)){
        cout <<  accumulated_costs.at(Rs.at(i)) - accumulated_costs.at(Ls.at(i)) << endl;
    }
    return 0;
}

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

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

int a[100][100], b[100][100];

int main(){

    int n, m, l;
    std::cin >> n >> m >> l;

    REP(i, n) REP(j, m) std::cin >> a[i][j];
    REP(j, m) REP(k, l) std::cin >> b[j][k];

    REP(i, n) {

        REP(k, l) {

            long long sum = 0;
            REP(j, m) sum += a[i][j] * b[j][k];

            if ( k ) std::cout << " ";
            std::cout << sum;
        }

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



Measured memory_bytes: 3176