akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n; cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    ll ans = 0;
    rep(i, n) REP(j, i+1, n) {
        ans += d[i]*d[j];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<Integer, Integer> numMap = new HashMap<>();
        int[] numList = new int[N];
        for (int i = 0; i < N; i++) {
            int num = sc.nextInt();
            Integer count = numMap.get(num);
            if (Objects.isNull(count)) {
                numMap.put(num, 1);
            } else {
                numMap.put(num, count + 1);
            }
            numList[i] = num;
        }

        long allPatterns = 0;
        for (Integer count : numMap.keySet()) {
            long counts = numMap.get(count);
            if (counts <= 1) {
                allPatterns += 0;
            } else {
                allPatterns += counts * (counts - 1L) / 2L;
            }
        }
        for (int var : numList) {
            System.out.println(allPatterns - (long) (numMap.get(var) - 1));
        }
        sc.close();
    }

}


Measured memory_bytes: 108904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); 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 long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];
const int MOD = 1000000007;

int main()
{
   int MAX = 101010;
   vector<int> is_prime(MAX, 1);
   is_prime[0] = 0, is_prime[1] = 0;
   Rep(i, 2, MAX)
   {
       if (!is_prime[i]) continue;
       for (int j = i * 2; j < MAX; j += i) is_prime[j] = 0;
   }

   vector<int> a(MAX, 0);
   rep(i, MAX)
   {
       if (i % 2 == 0) continue;
       if (is_prime[i] && is_prime[(i + 1) / 2]) a[i] = 1;
   }

   vector<int> s(MAX + 1, 0);
   rep(i, MAX) s[i + 1] = s[i] + a[i];

   int q; cin >> q;
   rep(i, q)
   {
       int l, r;
       cin >> l >> r;
       r++;

       cout << s[r] - s[l] << endl;
   }
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
int main(){
  int n;
  int h[101];
  int first;
  int sum = 0;

  scanf("%d", &n);

  int highest = 0;

  for(int cnt = 0; cnt < n; cnt++){
    scanf("%d", &h[cnt]);
    
    int ok = 1;
    if (h[cnt] >= highest) {
      sum++;
      highest = h[cnt];
    }
  }

  printf("%d", sum);
  printf("\n");
  
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
    long long n,y,i,j,k;
    scanf("%lld%lld",&n,&y);
    for(i=0;i<n+1;i++){
        for(j=0;j<n-i+1;j++){
            k = n-i-j;
            if(i*10000+j*5000+k*1000==y){
                printf("%lld %lld %lld",i,j,k);
                return 0;
            }
        }
    }
    printf("-1 -1 -1");
}


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

using namespace std;

const int INF = 1 << 29;

struct edge {
    int s, t, d;
};

int main() {

    int V, E, r;
    cin >> V >> E >> r;

    vector<edge> G;
    int d[V];

    for (int i = 0; i < E; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        G.emplace_back((edge) {s, t, d});
    }

    fill(d, d + V, INF);
    d[r] = 0;
    bool negative = false;

    for (int i = 0; i <= V; i++) {
        for (edge e : G) {
            if (d[e.s] != INF && d[e.t] > d[e.s] + e.d) {
                d[e.t] = d[e.s] + e.d;
                if (i == V) {
                    negative = true;
                    goto outer;
                }
            }
        }
    }
    outer:

    if (negative) {
        cout << "NEGATIVE CYCLE" << endl;
    } else {
        for (int i = 0; i < V; i++) {
            cout << (d[i] != INF ? to_string(d[i]) : "INF") << endl;
        }
    }
}


Measured memory_bytes: 3220
#include <iostream>
#include <vector>
#include <cctype>

using namespace std;

int main()
{
	string S;
	cin >> S;
	int N = S.size();
	vector<string> s(N);
	for (int i = 0; i < N; i++)
	{
		s[i] = S.substr(i, 1);
	}
	
	bool isAC = true;
	if (s[0] != "A")
	{
		isAC = false;
	}
	
	int CCount = 0;
	for (int i = 1; i < N; i++)
	{
		// 大文字の場合
		if (isupper(*s[i].c_str())) {
			// i = 1の場合もあるので、注意 文字列ACC
			if (i == 1 ||
			    i == N - 1 ||
			    s[i] != "C")
			{
				isAC = false;
			}
			
			CCount++;
		}
	}
	
	// Cが1より大きいの場合
	if (CCount != 1)
	{
		isAC = false;
	}
	
	if (isAC == true)
	{
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
const double eps=1e-6;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const int N=5e2+5;
int c[N],s[N],f[N];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        rep(i,1,n) scanf("%d%d%d",&c[i],&s[i],&f[i]);
        rep(i,1,n+1)
        {
            int ans=0;
            rep(j,i,n)
            {
                if(ans<s[j]) ans=s[j];
                else if((ans-s[j])%f[j]) ans+=(f[j]-(ans-s[j])%f[j]);
                ans+=c[j];
            }
            printf("%d\n",ans);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#define N 10000
using namespace std;
int Change(string);
int Change_sup(string);
struct data{
  int s,g;
  bool operator<(const data & right)const{
    if(s!=right.s) return s<right.s;
    return g<right.g;
  }
};
int main(){
  int n,flag[N],com,cnt,i,j;
  string ins,ing;
  struct data d[N];
  while(1){
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> ins >> ing;
      d[i].s=Change(ins);
      d[i].g=Change(ing);
      flag[i]=0;
    }
    sort(d,d+n);
    cnt=0;
    for(i=0;i<n;i++){
      if(flag[i]==0){
	flag[i]=1;
	cnt++;
	com=d[i].g;
	for(j=i+1;j<n;j++){
	  if(com<=d[j].s&&flag[j]==0){
	    flag[j]=1;
	    com=d[j].g;
	  }
	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
int Change(string str){
  int r;
  string a,b,c;
  a=str.substr(0,2);
  b=str.substr(3,2);
  c=str.substr(6,2);
  r=Change_sup(a+b+c);
  return r;
}
int Change_sup(string str){
  int len=str.size(),x=1,ret=0,i=0;
  while(len){
    ret=ret*x+(str[i]-'0');
    x=10;
    i++;
    len--;
  }
  return ret;
}

Measured memory_bytes: 1344
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int n,m,f[305][305][305],g[305][305][305];
char s[305];
int main(){
	scanf("%s",s+1);
	scanf("%d",&m);
	n=strlen(s+1);
	for(int i=1;i<=n;i++){
		for(int p=n;p;p--){
			for(int j=0;j<=m;j++){
				f[i][p][j]=max(f[i-1][p][j],f[i][p+1][j]);
				g[i][p][j]=f[i][p][j];
				if(s[i]==s[p]) f[i][p][j]=max(f[i-1][p+1][j]+1,f[i][p][j]);
				if(j) f[i][p][j]=max(f[i][p][j],f[i-1][p+1][j-1]+1);
			}
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++) ans=max(ans,max(g[i][i][m]*2,f[i][i][m]*2-1));
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 221056
s = input()
len_s = len(s)
p = input()
len_p = len(p)
for i in range(len_s):
    k = ""
    for j in range(len_p):
        k += s[(i+j)%len_s]
    if k == p:
        print("Yes")
        break
else:
    print("No")


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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N, Q; cin >> N >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21736
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int[] prefixSum = new int[n];
      prefixSum[0] = sc.nextInt() % m;
      for(int i = 1; i < n; i++)
        prefixSum[i] = (sc.nextInt() + prefixSum[i-1]) % m;

      Map<Integer, Long> remainderCnt = new HashMap<>();
      remainderCnt.put(0, 1L);
      long cnt = 0L;
      for(int r : prefixSum) {
        if(remainderCnt.containsKey(r)) {
          cnt += remainderCnt.get(r);
          remainderCnt.put(r, remainderCnt.get(r) + 1);
        } else 
          remainderCnt.put(r, 1L);
      }
      System.out.println(cnt);
  }
}

Measured memory_bytes: 52744
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 N, M;
	cin >> N >> M;
	vector<vector<i64>> jobs(M + 1);
	REP(i, N)
	{
		int A, B;
		cin >> A >> B;
		if (A > M)
			continue;
		jobs[M - A].push_back(B);
	}

	priority_queue<i64> q;
	i64 ans = 0;
	for (i64 i = M - 1; i >= 0; --i)
	{
		for (i64 b : jobs[i])
		{
			q.push(b);
		}
		if (!q.empty())
		{
			ans += q.top();
			q.pop();
		}
	}

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


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

int main() {
	int r,g,b,n;
	int ans;
	int remainder, nr;
	int green;
	ans = 0;
	cin >> r >> g >> b >> n;
	for (int i = 0; i <= n/r; i++) {
		remainder = n - (r*i);
		green = remainder / g;
		if (remainder == 0) {
			ans++;
		}
		else{
			for (int j = 0; j <= green; j++){
				nr = remainder - j*g;
				if (nr == 0){
					ans++;
				}
				else if (nr > 0 && nr % b == 0){
					ans++;
				}

			}
		}

		
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n, m, sum=0, max=-1;
  scanf("%d", &n);
  for(int i=0;i<n;i++){
    scanf("%d", &m);
    if(m > max) max = m;
    sum += m;
  }
  sum -= max/2;
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
  	cin>>s;
  	int flag=0,i,j,k,ans=0,tmp,c=0,n=s.length();
  
  	for(i=0;i<n;i++){
		for(j=i;j<n;j++){
          flag=0;
          for(k=i;k<=j;k++){
          	if(s[k]!='A' && s[k]!='T' && s[k]!='G' && s[k]!='C'){
              flag=1;
            	break;
            }
          }
            if(flag==0){
              tmp=j-i+1;
              if(tmp>ans){
					ans=tmp;
           		 }
            
            }
       
        }
    }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
/*ITS FUCKING O(N) now
GET ACCEPTED FOR FUCK'S SAKE*/
#define _USE_MATH_DEFINES
 
#include <cmath>

#include <iostream>
# include <bits/stdc++.h>
using namespace std;

long long powerexp(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
int gcd(int a, int b)
{
    int c = a % b;
    while(c != 0)
    {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}
void PrintVector(vector<long long int> v,long long int n)
{
 
    for(int i=v.size()-1;i>=0;i--)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void Takevector(vector<long long int> &v,long long int n)
{
  for(long long int i=0;i <n;i++)
  { long long int number;
    cin>>number;
    v.push_back(number);
  }
}
typedef long long int ll;
typedef vector<long long int> vi;

#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define scl(x)         ll x;       scanf("%lld", &x);
#define scll(x, y)     ll x, y;    scanf("%lld %lld", &x, &y);
#define sclll(x, y, z) ll x, y, z; scanf("%lld %lld %lld", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
#define nl cout<<"\n";
int min(int x, int y)  
{  
    return (x < y)? x: y;  
      
}  
  
int main()
{
  int flag=0;
  ll sum=0;
  int flag1=1;
  ll tot=0;
  int ans=0;
  map<int,int>m;
  vi v;
  set<int>st;
  string s;
  sciii(k,a,b);
  for(int i=a;i<=b;i++)
  {
    if(i%k==0)
    {
      cout<<"OK";
      flag=1;
      break;
    }
  }
  if(flag==0)
  {
    cout<<"NG";
  }
   
    return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<vector<pair<int,pair<int,int> > > >adj;
int n, l;

int timer;
vector<int> tin, tout;
vector<vector<int>> up;
set<pair<int,int> >s[100005];
vector<int>mm[100004];
map<int,pair<int,int> >ans[100005];
int dis[100005];
int cnt[100005];
int hgt[100005];
void dfs(int v, int p)
{
    tin[v] = ++timer;
    up[v][0] = p;
    for (int i = 1; i <= l; ++i)
        up[v][i] = up[up[v][i-1]][i-1];

    for (auto u : adj[v]) {
        if (u.first != p)
            dfs(u.first, v);
    }

    tout[v] = ++timer;
}

bool is_ancestor(int u, int v)
{
    return tin[u] <= tin[v] && tout[u] >= tout[v];
}

int lca(int u, int v)
{
    if (is_ancestor(u, v))
        return u;
    if (is_ancestor(v, u))
        return v;
    for (int i = l; i >= 0; --i) {
        if (!is_ancestor(up[u][i], v))
            u = up[u][i];
    }
    return up[u][0];
}

void preprocess(int root) {
    tin.resize(n+1);
    tout.resize(n+1);
    timer = 0;
    l = ceil(log2(n+1));
    up.assign(n+1, vector<int>(l + 1));
    dfs(root, root);
}

void dfs2(int ver,int pr,int x)
{
  hgt[ver]=x;
  for(auto i:mm[ver])
  {
    ans[ver][i].first=dis[i];
    ans[ver][i].second=cnt[i];    
  }
  for(auto i:adj[ver])
  {
    if(i.first!=pr)
    {
      dis[i.second.first]+=i.second.second;
      cnt[i.second.first]++;
      dfs2(i.first,ver,x+i.second.second);
      dis[i.second.first]-=i.second.second;
      cnt[i.second.first]--;
    }
  }
}

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

  #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout);
      }
  #endif  

  int q;
  cin>>n>>q;
  adj.resize(n+1);
  int x,y,z,w;
  for(int i=0;i<n-1;i++)
  {
    cin>>x>>y>>z>>w;
    adj[x].push_back({y,{z,w}});
    adj[y].push_back({x,{z,w}});
  }

  preprocess(1);
  vector<pair<pair<int,int>,pair<int,int> > >qq;

  for(int i=0;i<q;i++)
  {
    cin>>x>>y>>z>>w;
    qq.push_back({{z,w},{x,y}});
    int madar=lca(z,w);
    mm[z].push_back(x);
    mm[w].push_back(x);
    mm[madar].push_back(x);
  }
  dfs2(1,0,0);
  for(auto i:qq)
  {
    int x=i.first.first;
    int y=i.first.second;
    int z=i.second.first;
    int w=i.second.second;
    int madar=lca(x,y);
    int fi=-ans[x][z].first-ans[y][z].first+2*ans[madar][z].first;
    int tot=ans[x][z].second+ans[y][z].second-2*ans[madar][z].second;
    tot*=w;
    fi+=tot;
    fi+=hgt[x]+hgt[y]-2*hgt[madar];
    cout<<fi<<"\n";
  }
}

Measured memory_bytes: 74108
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: ident) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let (n, m) = parse!(it, 2);
    let mut ret = vec![None; n];
    for _ in 0..m {
        let (s, t): (usize, usize) = parse!(it, 2);
        match ret[s - 1] {
            None => ret[s - 1] = Some(t),
            Some(r) => {
                if t != r {
                    println!("{}", -1);
                    return;
                }
            }
        };
    }
    if n > 1 && ret[0] == Some(0) {
        println!("{}", -1);
        return;
    }
    if ret[0] == None {
        if n == 1 {
            ret[0] = Some(0);
        } else {
            ret[0] = Some(1);
        }
    }
    println!(
        "{}",
        ret.into_iter()
            .map(|x| match x {
                None => 0,
                Some(t) => t,
            })
            .map(|x| std::char::from_digit(x as u32, 10).unwrap())
            .collect::<String>()
    );
}


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

int main(){
    int i,k,t,big=0;
    cin >> k >> t;
    vector<int> a(t);
    for(i=0;i<t;i++){
        cin >> a.at(i);
        if(i==0)big=a.at(i);
        if(big<a.at(i))big=a.at(i);
    }
    if(k/2>=big){cout << 0 << endl;}
    else{
        cout << k-2*(k-big)-1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    long r, d, x;
    scan(r, d, x);

    foreach (i ; 0 .. 10) {
        x = r * x - d;
        writeln(x);
    }
}





















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final long A = sc.nextLong();
        final float B = sc.nextFloat();
        long b = (long) ((B+0.0001f) * 100 / 1);
        System.out.println(A * b / 100);
    }
}


Measured memory_bytes: 28956
import java.io.PrintWriter;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int h = sc.nextInt();
    int w = sc.nextInt();

    char[][] arr = new char[h][w];

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

    List<Integer> list = new ArrayList<>();

    int ans = Integer.MAX_VALUE;

    int[][] visit = new int[h][w];


    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        for (int i=0; i<h; i++) {
            arr[i] = sc.next().toCharArray();
        }

        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                visit[i][j] = Integer.MAX_VALUE;
            }
        }



        dfs(0, 0, 0);

        PrintWriter out = new PrintWriter(System.out);
        if (arr[0][0]=='#') {
            out.print(ans+1);
        } else {
            out.print(ans);
        }
//        out.print(list);
        out.flush();

    }

    int dfs(int y, int x, int cnt) {
        if (y==h-1 && x==w-1) {
            ans = Math.min(ans, cnt);
        }

        visit[y][x] = cnt;
        char c = arr[y][x];
        if (ans!=Integer.MAX_VALUE && ans<cnt) return Integer.MAX_VALUE;
        if (c=='.') {
            for (int i=0; i<2; i++) {
                int nx = x + dx[i];
                int ny = y + dy[i];

                if (0 <= nx && nx < w && 0 <= ny && ny < h) {
                    if (arr[ny][nx] == '.') {
                        if (cnt<visit[ny][nx]) dfs(ny, nx, cnt);
                    } else {
                        if (cnt+1<visit[ny][nx]) dfs(ny, nx, cnt + 1);
                    }
                }
            }
        } else {
            for (int i=0; i<2; i++) {
                int nx = x + dx[i];
                int ny = y + dy[i];


                if (0 <= nx && nx < w && 0 <= ny && ny < h) {
                    if (arr[ny][nx] == '.') {
                        if (cnt<visit[ny][nx]) dfs(ny, nx, cnt);
                    } else {
                        if (cnt<visit[ny][nx]) dfs(ny, nx, cnt);
                    }
                }
            }
        }
        return ans;
    }
}

Measured memory_bytes: 23428
N = int(input())
A = list(map(int ,input().split()))
B = list(map(int ,input().split()))
C = list(map(int ,input().split()))
value = 0

A = [i-1 for i in A]

for ind,i in enumerate(A):
  value += B[i]
  if ind != N-1:
    if A[ind+1] == i+1:
      value += C[i]
    
print(value)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
 
bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/


signed main(){
	int n;cin>>n;
	int k;
	rep(i,30){
		if((1<<i)<=n&&(1<<(i+1))>n){
			k=i;break;
		}
	}
	int l=1<<k,m=n-(1<<k);
	vector<pair<P,int>>ans;
	rep(i,k){
		ans.push_back({{i,i+1},1<<i});
		ans.push_back({{i,i+1},0});
	}
	rep(i,k){
		if(m>>i&1){
			ans.push_back({{i,k},l});
			l+=1<<i;
		}
	}
	cout<<k+1<<" "<<ans.size()<<endl;
	for(auto p:ans){
		cout<<p.first.first+1<<" "<<p.first.second+1<<" "<<p.second<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
int32_t main() {
    fast_io();
    int n;
    cin >> n;
    int a[n];
    map <int, int> mp, mq;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        mp[i + a[i]]++;
        mq[i - a[i]]++;
    }
    int ans = 0;
    for (auto x : mp)
    {
        ans += (x.second * mq[x.first]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 39548
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	int n,k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	vi dp(n,INT_MAX);
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for (int i = 2; i < n; ++i)
	{
		for (int j = i-1, jump=0; j >= 0 && jump < k; --j,jump++)
		{
			dp[i]=min(abs(a[i]-a[j])+dp[j],dp[i]);
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
import itertools

def solve(q, h, s, d, n):
    records = [(1, q), (2, h), (4, s), (8, d)]
    best = 10**30
    for p in itertools.permutations(range(4)):
        x = 4 * n
        cur = 0
        for i in p:
            size, price = records[i]
            amount = x // size
            cur += amount * price
            x -= size * amount
        cur += x * q
        best = min(best, cur)
    return best

q, h, s, d = map(int, input().split())
n = int(input())
print(solve(q, h, s, d, n))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define MOD  1000000007
#define INF  0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
typedef long long ll;

ll N,W;
ll w[110];
ll v[110];
ll dp[110][110][1010];

int main() {
    
    cin >> N >> W;
    REP(i,N) cin >> w[i] >> v[i];
    
    ll w0 = w[0];
    REP(i,N) w[i] -= w0;
    
    REP(i,110)REP(k,110)REP(j,1010) dp[i][k][j] = 0;
    
    for(int i=0;i<N;i++) {
        for(int k=0;k<N;k++){
            REP(j,1000) dp[i+1][k+1][j] = dp[i][k+1][j];
            RREP(j,1000) {
                if(j-w[i]>=0) {
                    dp[i+1][k+1][j] = max(dp[i+1][k+1][j],dp[i][k][j-w[i]] + v[i]);
                }
            }
        }
    }
    
    
    ll ans = 0;
    for(int k=1;k<=N;k++){
        ll Wt = W - w0 * k;
        REP(i,min((ll)1000,max((ll)0,Wt+1))) ans = max(ans,dp[N][k][i]);
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 95744
#include <stdio.h>

int main(){
  int n, k;
  int x[110] = {};
  int dist = 0;

  scanf("%d%d", &n, &k);
  for(int i = 1; i <= n; i++){
    scanf("%d", &x[i]);
  }

  for(int i = 1; i <= n; i++){
    if(x[i] - 0 < k - x[i]){
      dist += 2*x[i];
    }else{
      dist += 2*(k - x[i]);
    }
  }

  printf("%d\n", dist);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                                #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                 
                                        using namespace std;

int par[500100],ranks[500100],kosuu[500100];     

void shoki(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		ranks[i]=0;
		kosuu[i]=1;
	}
}

int root(int x){
	return par[x]==x ? x : par[x]=root(par[x]);
}

bool same(int x,int y){
return root(x)==root(y);
}

void unite(int x,int y){
 x=root(x);
 y=root(y);
	int xx=kosuu[x],yy=kosuu[y];
 if(x==y) return;
	if(ranks[x]<ranks[y]){
		par[x]=y;
		kosuu[y]=yy+xx;
	}
 else {
	par[y]=x;
	if(ranks[x]==ranks[y]) ranks[x]=ranks[x]+1;
 	kosuu[x]=yy+xx;
 }
	return;
}

int gcd(int a1,int a2){
	if(a1<a2) return gcd(a2,a1);
	if(a2==1) return 1;
	if(a1%a2==0) return a2;
	return gcd(a2,a1%a2);
}


int rui2(int e,int r){
	if(r==0) return 1;
	if(r==1) return e%inf;
	if(r%2==1) return (e*rui2(e,r-1))%inf;
	int w=rui2(e,r/2)%inf;
	return (w*w)%inf;
}

bool heikou(pa a,pa b){
	return (a.first*b.second==a.second*b.first);
}

pa po[100];
int n;
bool sumi[20]={0};
vector<pa> ve;
int ans=0;
void dfs(int nokori,int kazu){
	if(nokori==0){
		ans=max(ans,kazu);
		return;
	}
	
	int s=0;
	while(sumi[s])s++;
	sumi[s]=1;
	for(int i=s+1;i<n;i++){
		if(sumi[i])continue;
		int r=kazu;
		pa sabun=mp(po[i].first-po[s].first,po[i].second-po[s].second);
		for(auto v:ve)if(heikou(v,sabun))r++;
		sumi[i]=1;
		ve.pb(sabun);
		dfs(nokori-2,r);
		ve.pop_back();
		sumi[i]=0;
		
	}
	sumi[s]=0;
	
}


            signed main(){
   cin>>n;
            	for(int i=0;i<n;i++)cin>>po[i].first>>po[i].second;
            	ans=0;
            	dfs(n,0);
            	cout<<ans<<endl;
            	return 0;
            }
             

Measured memory_bytes: 3088
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::cmp;
use std::f64::consts;

fn main() {
    let n: i32 = read();
    let mut vec: Vec<i32> = (0..n).map(|_| read()).collect();
    vec.sort();
    vec.reverse();

    let longest = vec[0];

    let mut sum = 0;
    for (index, &i) in vec.iter().enumerate() {
        if index == 0 {
            continue;
        }
        sum += i;
    }

    println!("{}", if longest < sum {"Yes"} else {"No"});
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// 最大公約数
fn gcd(a: i32, b: i32) -> i32 {
    match b {
        0 => a,
        _ => gcd(b, a % b)
    }
}

// 最小公倍数
fn lcm(a: i32, b: i32) -> i32 {
    a * b / gcd(a, b)
}

// 階乗
fn kaijou(n: i32)->i32 {
    if n == 1 {
        return n;
    }
    return n * kaijou(n-1);
}

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

const int N = 1e5 + 5;

typedef long long LL;

int n , m , tot;
LL cnt[N] , S[N] , stk[N] , num[N] , x;

int main(void) {
	cin >> n >> m;
	stk[++ tot] = n;
	for(int i = 1;i <= m;++ i) {
		scanf("%lld" , &x);
		while(tot && stk[tot] >= x) tot --;
		stk[++ tot] = x;
	}
	num[tot] = 1;
	int whi;
	for(int i = tot;i >= 1;-- i) {
		if(i == 1) {
			S[stk[i]] += num[i];
			break;
		}
		num[i - 1] += (stk[i] / stk[i - 1]) * num[i];
		stk[i] %= stk[i - 1];
		while(stk[i] >= stk[1]) {
			whi = upper_bound(stk + 1 , stk + i , stk[i]) - stk - 1;
			num[whi] += num[i] * (stk[i] / stk[whi]); stk[i] %= stk[whi];
		}
		S[stk[i]] += num[i];
	}
	for(int i = n;i >= 1;-- i) S[i] += S[i + 1];
	for(int i = 1;i <= n;++ i)printf("%lld\n" , S[i]);
}

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

uint64_t getLucasNumber(int number)
{
  if( number == 0 ){
    return 2;
  }
  else if( number == 1 ){
    return 1;
  }
  else{
    vector<uint64_t> tmp(2);
    tmp.at(0) = 2;
    tmp.at(1) = 1;
    for( int i=2; i<=number-1; i++ ){
      if( (i % 2) == 0 ){
        tmp.at(0) += tmp.at(1);
      }
      else{
        tmp.at(1) += tmp.at(0);
      }
    }
    return ( tmp.at(0) + tmp.at(1) );
  }
}

int main() {
  int N;
  cin >> N;
  
  uint64_t lucasNumber = getLucasNumber(N);
  
  cout << lucasNumber << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int power(int num)
{
    int p=1;
    for(;0<num;num--)p*=10;
    return p;
}
int main() {
    int n,m,a[3]={15,3,5};
    while(cin>>m>>n,n,m){
        string str,fb[3]={"FizzBuzz","Fizz","Buzz"};
        bool player[1000]={};
        for(int i=1,now=0,out=m;i<=n;i++,now=(now+1)%m){
			cin>>str;
			if(out>1){
				int num=0,co=-1;
				while(player[now])now=(now+1)%m;
				for(int j=0;j<3&&co<0;j++)if(i%a[j]<1)co=j;
				for(int j=0;j<str.size();j++)num+=(str[j]-'0')*power(str.size()-1-j);
				if(co>-1&&str!=fb[co]||co<0&&i!=num)player[now]=1;
				if(player[now])out--;
			}
		}
		for(int i=0,co=0;i<m;i++){
			if(!player[i]&&co>0)cout<<" ";
			if(!player[i]){
				cout<<i+1;
				co++;
			}
		}
		cout<<endl;
	}
}

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

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define RREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define RFOR(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[ ";
    for (auto a : v) os << a << " ";
    os << "]";
    return os;
}

int main() {
    int N;
    cin >> N;
    vector<ll> num(1e5 + 1);
    ll ans = 0;
    REP(i, N) {
        int a;
        cin >> a;
        num[a]++;
        ans += a;
    }

    int Q;
    cin >> Q;
    REP(i, Q) {
        ll b, c;
        cin >> b >> c;
        num[c] += num[b];
        ans += (num[b] * c) - (num[b] * b);
        cout << ans << endl;
        num[b] = 0;
    }

    return 0;
}

Measured memory_bytes: 4056
from collections import deque
import sys
sys.setrecursionlimit(10**7) #再帰関数の呼び出し制限

N,M = map(int,input().split())
concat = [ [] for i in range(N)]
que = deque([1])
check = [-1 for i in range(N)]
check[0] = 0 

for _ in range(M):
    a,b = map(int,input().split())
    concat[a-1].append(b)
    concat[b-1].append(a)


def bfs():
    if len(que)==0:
        return
    out = que.popleft()
    for i in concat[out-1]:
        if check[i-1]==-1:
            check[i-1]=out
            que.append(i)
    bfs()

bfs()
if not -1 in check:
    print("Yes")
    for i in range(1,N):
        print(check[i])
else:
    print("No")


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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

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

/// 最小共通部分列: longest common subsequence
/// O(|S||T|)
int lcs(const string& s, const string& t) {
    int slen = s.size(), tlen = t.size();
    vector<vector<int>> dp(slen + 5, vector<int>(tlen + 5, 0));
    rep(i, 0, slen) rep(j, 0, tlen) {
        if (s[i] == t[j]) {
            chmax(dp[i + 1][j + 1], dp[i][j] + 1);
        }
        chmax(dp[i + 1][j + 1], dp[i + 1][j]);
        chmax(dp[i + 1][j + 1], dp[i][j + 1]);
    }

    return dp[slen][tlen];
}
//---------------------------------------------------------------------------------------------------

signed main() {
    int n;
    cin >> n;
    rep(i, 0, n) {
        string s, t;
        cin >> s >> t;
        cout << lcs(s, t) << "\n";
    }
}



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

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll a;
  long double b;
  cin >> a >> b;

  cout << (ll)(a * b) << endl;
  return 0;
}

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

double x[200],y[200];
double ans[2000];

int main(){
	int n;scanf("%d",&n);
	rep(i,n)scanf("%lf%lf",&x[i],&y[i]);
	double R=1e11;
	double K=100000;
	rep(i,K){
		double rad=2*M_PI*i/K;
		double X=cos(rad)*R,Y=sin(rad)*R;
		double Min=INFINITY;
		int id=-1;
		rep(j,n){
			double d=hypot(X-x[j],Y-y[j]);
			if(d<Min){
				Min=d;id=j;
			}
		}
		ans[id]+=1/K;
	}
	rep(i,n){
		printf("%.7lf\n",ans[i]);
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

struct mint {
    const int mod = 998244353;
    long long x;
    
    mint (long long x = 0) : x((x % mod + mod) % mod) {
        
    }
    
    mint& operator=(const long long a) {
        x = a % mod;
        return *this;
    }
    
    mint& operator=(const mint a) {
        x = a.x % mod;
        return *this;
    }
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    
    mint& operator-=(const mint a) {
        if ((x += (mod - a.x)) >= mod) x -= mod;
        return *this;
    }
    
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    
    mint inv() const {
        return pow(mod - 2);
    }
    
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, s;
    cin >> n >> s;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<vector<mint>> dp(2, vector<mint>(s + 1, 0));
    dp[1][0] = 1;
    rep(i, n) {
        rep(j, s + 1) dp[i % 2][j] = dp[(i + 1) % 2][j] * 2;
        rreps(j, a[i], s + 1) {
            dp[i % 2][j] += dp[(i + 1) % 2][j - a[i]];
        }
    }
    cout << dp[(n - 1) % 2][s].x << endl;
    return 0;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int n, ans = 0;
void dfs(string s) {

  if (s != "") {
    ll x = stol(s);
    if (x > n)
      return;

    vector<int> ok(10, 0);
    rep(i, 0, (int)s.size()) { ok[s[i] - '0']++; }
    if (ok[3] && ok[5] && ok[7])
      ans++;
  }

  dfs(s + "3");
  dfs(s + "5");
  dfs(s + "7");
}

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

  cin >> n;
  dfs("");
  cout << ans << endl;
}


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

int main(){
  int n;  cin >> n;
  vector<P> p(n);  rep(i,n) cin >> p[i].second >> p[i].first;
  sort(p.begin(), p.end());
  ll t = 0;
  rep(i,n){
    t += p[i].second;
    if(t > p[i].first){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 1792
MOD = 10 ** 9 + 7


def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs


def modNum(N, a):
    global MOD
    ans = 1
    for i in range(a):
        ans *= (N - i)
        ans %= MOD
    return ans


N, a, b = map(int, input().split())
total = pow(2, N, MOD) - 1
modFacts, invs = prepare(max(a, b))


A = (modNum(N, a) * invs[a]) % MOD
B = (modNum(N, b) * invs[b]) % MOD

print((total - A - B) % MOD)


Measured memory_bytes: 42736
#include <stdio.h>

int main() {
	int i, n, h[20], max, cont = 1;

	scanf("%d", &n);

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

	max = h[0];
	for (i = 1; i < n; i++) {
		if (h[i] >= max) {
			max = h[i];
			cont++;
		}
	}

	printf("%d\n", cont);

	return 0;
}

Measured memory_bytes: 128