akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

long long gcd(long long a, long long b){
    while(b != 0){
        long long tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}

void integerFactorization(long long n, vector<pair<long long, int> >& factor)
{
    factor.clear();
    long long a = 2;
    while(a * a <= n){
        int b = 0;
        while(n % a == 0){
            ++ b;
            n /= a;
        }
        if(b > 0)
            factor.push_back(make_pair(a, b));
        ++ a;
    }
    if(n > 1)
        factor.push_back(make_pair(n, 1));
}

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

    long long g = gcd(a, b);

    vector<pair<long long, int> > v;
    integerFactorization(g, v);
    int ans = v.size() + 1;
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main(){
  unsigned int n;

  cin >> n;

  bitset<32> b(n),b1,b2;

  b1 = b << 1;
  b2 = b >> 1;

  cout << b << endl;
  cout << b.flip() << endl;
  cout << b1 << endl;
  cout << b2 << endl;

  return 0;
}



Measured memory_bytes: 3140
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#ifdef LOCAL
#include "debug.h"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

const int mx=5e5+5;

int ara[mx],bit[mx],last[mx],ans[mx];

struct ques
{
	int l,r,id;
} query[mx];

bool comp(ques a,ques b)
{
	return a.r<b.r;
}

void update(int idx,int val,int n)
{
	for(;idx<=n;idx+=(idx&-idx)) bit[idx]+=val;
}

int sum(int idx,int n)
{
	int tot=0;
	for(;idx>0;idx-=(idx&-idx)) tot+=bit[idx];
	return tot;
}

void solve()
{	
	memset(last,-1,sizeof last);
	
	int n,q;
	cin>>n>>q;
	
	for(int i=1;i<=n;i++) cin>>ara[i];
	
	for(int i=1;i<=q;i++)
	{
		cin>>query[i].l>>query[i].r;
		query[i].id=i;
	}
	
	sort(query+1,query+q+1,comp);
	
	int now=1;
	
	for(int i=1;i<=n;i++)
	{
		if(last[ara[i]]!=-1) update(last[ara[i]],-1,n);
		
		last[ara[i]]=i;
		update(i,1,n);
		
		while(now<=q && query[now].r==i)
		{
			ans[query[now].id]=sum(query[now].r,n)-sum(query[now].l-1,n);
			now++;
		}
	}
	
	for(int i=1;i<=q;i++) cout<<ans[i]<<"\n";
	
}	

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int t=1;
	//cin>>t;
	
	for(int i=1;i<=t;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


Measured memory_bytes: 17368
#include <stdio.h>
     
    int main(void) {
      int num[4];
     
      scanf("%d", &num[0]);
      num[3] = num[0] / 1000;
      num[2] = (num[0] - num[3] * 1000) / 100;
      num[1] = (num[0] - num[3] * 1000 - num[2] * 100) / 10;
      num[0] = num[0] - num[3] * 1000 - num[2] * 100 - num[1] * 10;
     
      if(num[0] == num[1] && num[0] == num[2]) {
        printf("Yes");
      }
      else if(num[1] == num[2] && num[1] == num[3]) {
        printf("Yes");
      }
      else if(num[0] == num[1] && num[1] == num[2] && num[2] == num[3]) {
        printf("Yes");
      }
      else {
        printf("No");
      }
     
      return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
using P = pair<ll, ll>;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    vec<P> p;
    vec<P> m;
    rep(i, N) {
        string s;
        cin >> s;
        int last = 0;
        int mn   = 0;
        for (auto e : s) {
            if (e == '(')
                ++last;
            else
                --last;
            mn = min(mn, last);
        }
        if (last >= 0)
            p.push_back({-mn, last});
        else
            m.push_back({-(mn - last), -last});
    }
    sort(all(p));
    sort(all(m));

    ll now1 = 0;
    for (auto [f, s] : p) {
        if(now1<f){
            cout << "No" << endl;
            return 0;
        }
        now1+=s;
    }
    ll now2 = 0;
    for (auto [f, s] : m) {
        if(now2<f){
            cout << "No" << endl;
            return 0;
        }
        now2+=s;
    }

    if(now1==now2){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

typedef long long ll;
const int maxLen = 200002;
int N = 0;
ll num[maxLen];

ll lowbit(ll x) {
	return x & (-x);
}

ll getSum(ll x) {
	ll res = 0;
	while (x > 0) {
		res += num[x];
		x -= lowbit(x);
	}
	return res;
}

ll update(ll x, ll d) {
	while (x <= N) {
		num[x] += d;
		x += lowbit(x);
	}
	return x;
}

ll d[maxLen];
ll s[maxLen];
ll st[maxLen];

int main() {
	int k = 0;
	cin >> N >> k;
	for (int i = 1; i <= N; i++) {
		cin >> d[i];
		d[i] -= k;
		s[i] = s[i - 1] + d[i];
		st[i] = s[i];
	}
	sort(st + 1, st + N + 1);
	for (int i = 1; i <= N; i++) {
		s[i] = lower_bound(st + 1, st + N + 1, s[i]) - st;
	}
	ll res = 0;
	for (int i = 1; i <= N; i++) {
		if (st[i] >= 0) res++;
		res += getSum(s[i]);
		update(s[i], 1);
	}
	cout << res << endl;
}

Measured memory_bytes: 6528
#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 main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int h, w;
  cin >> h >> w;

  map<char, int> mp;
  rep(i, 0, h) {
    string a;
    cin >> a;
    rep(j, 0, w) { mp[a[j]]++; }
  }

  if (h % 2 == 0 && w % 2 == 0) {
    for (auto m : mp) {
      if (m.second % 4) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
    return 0;
  }

  map<int, int> c;
  for (auto m : mp)
    c[m.second % 4]++;
  if (h & 1 && w & 1) {
    if (c[3] || c[1] != 1)
      cout << "No" << endl;
    else if (c[2] > (h - 1) / 2 + (w - 1) / 2)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
    return 0;
  }

  if (w & 1)
    swap(h, w);
  if (c[1] || c[3])
    cout << "No" << endl;
  else if (c[2] > w / 2)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


Measured memory_bytes: 3656
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#define _USE_MATH_DEFINES

#include<math.h>
#include<unordered_map>

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int main()
{
	int n;
	bool a[4][13] = { false };

	scanf("%d", &n);
	getchar();
	for (int i = 0; i < n; i++)
	{
		char suit;
		int rank;

		scanf("%c %d", &suit, &rank);
		getchar();

		switch (suit)
		{
		case 'S':
			a[0][rank - 1] = true;
			break;
		case 'H':
			a[1][rank - 1] = true;
			break;
		case 'C':
			a[2][rank - 1] = true;
			break;
		case 'D':
			a[3][rank - 1] = true;
			break;
		}
	}

	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 13; j++)
		{
			if (!a[i][j])
			{
				switch (i)
				{
				case 0:
					printf("S %d\n", j + 1);
					break;
				case 1:
					printf("H %d\n", j + 1);
					break;
				case 2:
					printf("C %d\n", j + 1);
					break;
				case 3:
					printf("D %d\n", j + 1);
					break;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3172
"use strict";

const main = input => {
  input = input.trim().split("\n");
  const K = parseInt(input[0].split(" ")[0]);
  const T = parseInt(input[0].split(" ")[1]);
  let a = input[1].split(" ").map((el)=>{
    return parseInt(el);
  });
  let max = a.reduce( function (previous, current) {
  	return previous > current ? previous:current;
  });
  if(max-1-(K-max) > 0){
    console.log(max-1-(K-max));
  }else{
    console.log(0);
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
    string S;
    int count =0;
    cin >> S;
    for(int i=0; i<3; i++){
        if (S.at(i) == 'o') count++;
    }
    cout << 700 + count*100 <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
#define ll long long
#include <cstdint>

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b)cout << c << endl;
	else if (b == c)cout << a << endl;
	else cout << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	double a;
	while(cin >> a)
	{
		double sum = a;
		for(int i = 0; i < 9; ++i)
		{
			if(i % 2 == 0)
			{
				a *= 2;
			}
			else
			{
				a /= 3;
			}
			sum += a;
		}
		printf("%.8f\n", sum);
	}
}

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

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

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

# define forn(i, n) for (ll i = 0; i < int(n); i++)
# define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
# define all(V) V.begin(), V.end()
# define rall(V) V.rbegin(), V.rend()
# define len(V) (int)V.size()
# define ll long long
# define ld long double
# define ff first
# define ss second
# define pb push_back
# define mp make_pair
# define endl '\n'
# define M_PI 3.14159265358979323846

void solve()
{
    int n; cin >> n;
    ll res = 0;
    for(int i = 1; i <= n; ++i) 
    {
        if(i % 3 != 0 && i % 5 != 0) res += i;
    }
    cout << res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    solve();
}


Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
#include <array>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <algorithm>
#include <map>
#include <cmath>
#include <stdlib.h>
#include <string.h>
#include <stack>

using namespace std;

typedef double db;
typedef long long ll;
typedef pair<int, int> PII;

int a, b;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
#define MAX(a,b) a>b? a:b
#define MIN(a,b) a>b? b:a


const int MOD = 1e9 + 7;
const ll INF=1e10;
const db PI = acos(-1.0);
const db EPS = 1e-10;


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


ll MAXX(vector<ll> a,ll k) {
	ll max = 0;
	REP(i, k) {
		if (a[i] >= max) max = a[i];
	}
	return max;
}

ll MINN(vector<ll> a,ll k) {
	ll min = INF;
	REP(i, k) {
		if (a[i] <= min)min = a[i];
	}
	return min;
}

ll SUM(vector<ll> a, ll k) {
	ll sum = 0;
	REP(i, k) {
		sum += a[i];
	}
	return sum;
}

db AVE(vector<ll> a, ll k) {
	db ave = SUM(a,k)/(db)k;
	return ave;
}

db VAR(vector<ll> a, ll k) {
	db ave,ave2,var;
	db sum = 0;
	REP(i, k) {
		sum += a[i] * a[i];
	}
	ave2 =sum/ k;
	ave = AVE(a,k);
	ave = pow(ave,2);
	var = ave2 - ave;
	return var;
}


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


void prime(int k) {
	int cnt = 0;
	for (int i = 2;i<k;i++) {
		if (k % i == 0) { cnt++; }
	}
	if (cnt == 0) cout << k << "は素数です。" << endl;
	else cout << k << "は素数ではありません。" << endl;
}


int main() {
	int n,cnt=1;
	cin >> n;
	vector<int> v(n);
	REP(i, v.size()) cin >> v[i];
	sort(v.begin(),v.end(),greater<int>());
	REP(i, v.size()-1) {
		if (v[i] == v[i + 1]) {
			continue;
		}
		cnt++;
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 384
class Dijkstra():
    """ ダイクストラ法
    重み付きグラフにおける単一始点最短路アルゴリズム

    * 使用条件
        - 負のコストがないこと
        - 有向グラフ、無向グラフともにOK

    * 計算量はO(E*log(V))

    * ベルマンフォード法より高速なので、負のコストがないならばこちらを使うとよい
    """
    class Edge():
        """ 重み付き有向辺 """
        def __init__(self, _to, _cost):
            self.to = _to
            self.cost = _cost

    def __init__(self, V):
        """ 重み付き有向辺
        無向辺を表現したいときは、_fromと_toを逆にした有向辺を加えればよい

        Args:
            V(int): 頂点の数
        """
        self.G = [[] for i in range(V)]  # 隣接リストG[u][i] := 頂点uのi個目の隣接辺
        self._E = 0  # 辺の数
        self._V = V  # 頂点の数

    @property
    def E(self):
        """ 辺数
        無向グラフのときは、辺数は有向グラフの倍になる
        """
        return self._E

    @property
    def V(self):
        """ 頂点数 """
        return self._V

    def add(self, _from, _to, _cost):
        """ 2頂点と、辺のコストを追加する """
        self.G[_from].append(self.Edge(_to, _cost))
        self._E += 1

    def shortest_path(self, s):
        """ 始点sから頂点iまでの最短路を格納したリストを返す
        Args:
            s(int): 始点s
        Returns:
            d(list): d[i] := 始点sから頂点iまでの最短コストを格納したリスト。
                     到達不可の場合、値はfloat("inf")
        """
        import heapq
        que = []  # プライオリティキュー（ヒープ木）
        d = [10**15] * self.V
        d[s] = 0
        heapq.heappush(que, (0, s))  # 始点の(最短距離, 頂点番号)をヒープに追加する

        while len(que) != 0:
            cost, v = heapq.heappop(que)
            # キューに格納されている最短経路の候補がdの距離よりも大きければ、他の経路で最短経路が存在するので、処理をスキップ
            if d[v] < cost: continue

            for i in range(len(self.G[v])):
                # 頂点vに隣接する各頂点に関して、頂点vを経由した場合の距離を計算し、今までの距離(d)よりも小さければ更新する
                e = self.G[v][i]  # vのi個目の隣接辺e
                if d[e.to] > d[v] + e.cost:
                    d[e.to] = d[v] + e.cost  # dの更新
                    heapq.heappush(que, (d[e.to], e.to))  # キューに新たな最短経路の候補(最短距離, 頂点番号)の情報をpush
        return d

def BellmanFord(edges,num_v,source):
  #グラフの初期化
  inf=float("inf")
  dist=[inf for i in range(num_v)]
  dist[source-1]=0

  #辺の緩和
  for i in range(num_v):
    for edge in edges:
      if edge[0] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
        dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
        if i==num_v-1: return -1

  return dist

N,M=map(int,input().split())
edges=[]
test=Dijkstra(N)
for i in range(0,M):
    a,b,c=map(int,input().split())
    edges.append([a,b,-c])
    test.add(b-1,a-1,1)

use=set([N-1])
for i in range(0,N-1):
    if test.shortest_path(N-1)[i]!=10**15:
        use.add(i)

useedges=[]
for i in range(0,M):
    a,b,c=edges[i]
    if a-1 in use and b-1 in use:
        useedges.append(edges[i])

ans=BellmanFord(useedges,N,1)
if ans==-1:
    print('inf')
else:
    print(-ans[N-1])


Measured memory_bytes: 71128
import sys


N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

ope = [list(map(int, x.split())) for x in sys.stdin.readlines()]

ope.sort(key=lambda x: -x[1])

mp = 0
ap = 0
cnt = 0
ans = 0

while cnt < N:
    a = A[ap]
    m = ope[mp][1] if mp < M else 0

    if m >= a:
        mc = min(ope[mp][0], N - cnt)
        ans += m * mc
        cnt += mc
        mp += 1
    else:
        ans += a
        cnt += 1
        ap += 1

print(ans)


Measured memory_bytes: 91032
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        for (int i = 1; ; i++){
            int a;
            a = input.nextInt();
            if (a == 0){
                break;
            }
            System.out.printf("Case %d: %d\n", i, a);
        }
    }

}


Measured memory_bytes: 67732
// STRIVER_79 
// Lets goto the next level 
// AIM 6* at CC and CM at CF *__* 

#include <algorithm>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define mod (int)(1e9 + 21)
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long
#define ll long long 
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define in(x) scanf("%intd", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define fi first
#define se second
#define kitna se
#define endl "\n"
#define pi pair<int, int>
#define LL long long 
const int MAXN = (int)((1e5) + 10);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
bool isPrime(int N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int nax =  (int)(1*1e5+10);

// int SPF[N+5];

// void SOF()
// {
//     SPF[1] = 1;
//     for (int i=2; i<N; i++)
//         SPF[i] = i;
//     for (int i=4; i<N; i+=2)
//         SPF[i] = 2;
 
//     for (int i=3; i*i<N; i++)
//         {
//         if (SPF[i] == i)
//             {
//             for (int kon=i*i; kon<N; kon+=i)
//                 if (SPF[kon]==kon)
//                    SPF[kon] = i;
//             }
//         }
// }
int a[nax];
int n; 
int dp[nax]; 
int k;
int func(int ind)
{
	if(ind==(n-1))
		return 0;
	else if(dp[ind]!=-1) return dp[ind];
	else
	{
		int ans = 1e9+5; 
		for(int i = 1;i<=k;i++)
		{
			if(ind+i<n)
				ans = min(ans,abs(a[ind+i]-a[ind]) + func(ind+i));

		}
		return dp[ind] = ans; 
	}

}





signed main(){

int t=1; 
//cin >> t;
// string s; 
// getline(cin,s);

while(t--)
{
    cin >> n >> k;
    for0(i,n) cin >> a[i]; 	
    ini(dp,-1); 
    cout << func(0); 

}

rr;
}


Measured memory_bytes: 11436
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;

#define mod 1000000007

int main()
{
    string s;
    cin >> s;
    stack<char> st;
    for(int i = 0; i < s.length(); i++){
        if(st.empty()){
            st.push(s[i]);
        } else if(st.top() == 'S' && s[i] == 'T'){
            st.pop();
        } else {
            st.push(s[i]);
        }
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 644
#include<iostream>
#include<algorithm>
using namespace std;
const int INF=0x3f3f3f3f,maxn=55;
int a[maxn];
int temp[maxn],n,m;
int main()
{
	int i,j,k,ans=0;
	cin>>n>>m;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(int l=0;l<=n;l++)
	{
		for(int r=n+1;r>l;r--)
		{
			int cnt=0,sum=0;
			for(i=1;i<=l;i++)
				temp[++cnt]=a[i];
			for(i=n;i>=r;i--)
				temp[++cnt]=a[i];
			if(m<cnt)
				continue;
			sort(temp+1,temp+cnt+1);
			for(i=cnt;i>=0;i--)
			{
				if(i<=m-cnt)
					sum+=max(temp[i],0);
				else
					sum+=temp[i];
			}
			ans=max(ans,sum);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
N,A,B,C=list(map(int, input().split()))
l=[int(input()) for i in range(N)]

def dfs(cur,a,b,c):
    if cur==N:
        if min(a,b,c)!=0:
            return abs(a-A)+abs(b-B)+abs(c-C)-30
        else:
            return 10**9+7
    else:
        ret0=dfs(cur+1,a,b,c)
        ret1=dfs(cur+1,a+l[cur],b,c)+10
        ret2=dfs(cur+1,a,b+l[cur],c)+10
        ret3=dfs(cur+1,a,b,c+l[cur])+10
        return min(ret0,ret1,ret2,ret3)
    
print(dfs(0,0,0,0))

Measured memory_bytes: 3064
// Created by sz
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 1e5 + 5;
int a,b,c;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> a >> b >> c;
    
    int give = min(a-b, c);
    cout << c- give << "\n";
    
    
    return 0;
}


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

using namespace std;

int main(){
    int s;
    int max = 1000000;
    vector<int> a(max);
    vector<bool> b(max,false);
    cin >> s;
    a.at(0) = s;
    int i = 0;
    b.at(s) = true;
    while(1){
        if(a.at(i)%2==0){
            a.at(i+1) = a.at(i)/2;
        }
        else if(a.at(i)%2 ==1){
            a.at(i+1) = 3*a.at(i)+1;
        }
        if(b.at(a.at(i+1))==true){
            cout << (i+2);
            return 0;
        }
        else{
            b.at(a.at(i+1)) = true;
            i ++;
        }
    }
}

Measured memory_bytes: 4224
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
		int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
		int h = inpt[0];
		int w = inpt[1];

		char[,] map = new char[h, w];
		for (int i = 0; i < h; i++) {
			string tmp = Reader.ReadLine();
			for (int j = 0; j < tmp.Length; j++) {
				map[i, j] = tmp[j];
			}
		}
		string ans = "Yes";

		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++)
			{
				if (map[i, j] != '#') {
					continue;
				}
				bool isMatch = false;
				for (int k = Math.Max(0, i - 1); k <= Math.Min(i + 1, h - 1); k++)
				{
					for (int l = Math.Max(0, j - 1); l <= Math.Min(j + 1, w - 1); l++)
					{
						if (k == i && l == j) {
							continue;
						}
						if (k != i && l != j) {
							continue;
						}

						if (map[k, l] == '#')
                        {
                            isMatch = true;
                            break;
                        }
					}
					if(isMatch){
						break;
					}
				}
				if(!isMatch) {
					ans = "No";
					break;
				}
			}
		}
		Console.WriteLine(ans);
	}


	public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


11 11
...#####...
.##.....##.
#..##.##..#
#..##.##..#
#.........#
#...###...#
.#########.
.#.#.#.#.#.
##.#.#.#.##
..##.#.##..
.##..#..##.



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;

int main(){
   int r; cin >> r;
   print(r * r * 3);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(all(d));
    int ans = 0;
    for (int i = 0; i <= 100000; i++)
    {
        if (d[0] > i)
            continue;
        int l = 0, r = n;
        while (r - l > 1)
        {
            int mid = (r + l) / 2;
            if (d[mid] <= i)
                l = mid;
            else
                r = mid;
        }
        if (l == n / 2 - 1)
            ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
	string s;
	cin >> s;
	string ans = "Yes";

	for (int i=0; i < s.size(); i++){
		if (i % 2 == 0 && (s[i] == 'R' || s[i] == 'U' || s[i] == 'D'))
			continue;
		else if(i % 2 == 1 && (s[i] == 'L' || s[i] == 'U' || s[i] == 'D'))
			continue;
		else
			ans = "No";
			break;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from itertools import product
N = int(input())
S = input()
S += S[0]


def isOK(x, y):
    WS = [-1] * (N + 2)
    WS[0] = x
    WS[1] = y
    for i in range(1, N + 1):
        if S[i] == "o":
            WS[i + 1] = WS[i - 1] if WS[i] else 1 - WS[i - 1]
        else:
            WS[i + 1] = 1 - WS[i - 1] if WS[i] else WS[i - 1]
    if WS[0] == WS[-2] and WS[1] == WS[-1]:
        return WS[:-2]
    else:
        return []


for x, y in product(range(2), repeat=2):
    ws = isOK(x, y)
    if len(ws) > 0:
        break

if len(ws) == 0:
    ans = -1
else:
    ans = ""
    for x in ws:
        if x:
            ans += "S"
        else:
            ans += "W"

print(ans)


Measured memory_bytes: 4852
#include <iostream>
#include <map>

using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

int ff(int n) {
    map<int, int> factors;
    for(int t=2; t<=n; t++) {
        int x = t;
        int p = 2;
        while(x>=p*p) {
            if(x%p==0) {
                x /= p;
                factors[p] += 1;
            } else {
                p += (p==2) ? 1 : 2;
            }
        }
        if(x>1) factors[x] += 1;
    }
    ll res = 1;
    for(auto &a : factors) {
        res = (res * (a.second+1)) % MOD;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    cout << ff(n) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 2e5 + 8;

namespace ST {
	int t[4 * N];

	void pull(int v) {
		t[v] = max(t[2 * v + 1], t[2 * v + 2]);
	}

	void set(int v, int l, int r, int pos, int val) {
		if (l + 1 == r) {
			t[v] = val;
		} else {
			int m = (r + l) >> 1;
			if (pos < m) {
				set(2 * v + 1, l, m, pos, val);
			} else {
				set(2 * v + 2, m, r, pos, val);
			}
			pull(v);
		}
	}

	void query(int v, int l, int r, int ql, int qr, int &ans) {
		if (r <= ql || qr <= l) {
			//
		} else if (ql <= l && r <= qr) {
			ans = max(ans, t[v]);
		} else {
			int m = (r + l) >> 1;
			query(2 * v + 1, l, m, ql, qr, ans);
			query(2 * v + 2, m, r, ql, qr, ans);
		}
	}

	void set(int pos, int val) {
		set(0, 0, N, pos, val);
	}

	int mx(int l, int r) {
		int ans = 0;
		query(0, 0, N, l, r, ans);
		return ans;
	}
}

int a[N];
vector<int> g[N];

int ans[N];

void dfs(int cur, int p) {
	ans[cur] = ST::mx(0, N);
	for (auto t : g[cur]) {
		if (t != p) {
			int oval = ST::mx(a[t], a[t] + 1);
			ST::set(a[t], ST::mx(0, a[t]) + 1);
			dfs(t, cur);
			ST::set(a[t], oval);
		}
	}
}

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

	int n;
	cin >> n;
	vector<int> sn;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sn.push_back(a[i]);
	}
	sort(sn.begin(), sn.end());
	sn.resize(unique(sn.begin(), sn.end()) - sn.begin());
	for (int i = 0; i < n; i++) {
		a[i] = lower_bound(sn.begin(), sn.end(), a[i]) - sn.begin();
	}
	for (int i = 0; i + 1 < n; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	ST::set(a[0], 1);
	dfs(0, -1);
	for (int i = 0; i < n; i++) {
		cout << ans[i] << ' ';
	}
	cout << '\n';
}


Measured memory_bytes: 30496
r = {}
b = []
c = {}
while 1
	a = gets.split(",").map &:to_i
	break if a[0] == 0
	r[a[0]] = a[1]
	b = b - [a[1]]
	b.push(a[1])
end
b.sort!.reverse!
b.size.times{ |i|
	c[b[i]] = i+1
}
while a = gets
	p c[r[a.to_i]]
end

Measured memory_bytes: 6108
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> s(M);
    rep(i, 0, M) {
        int k;
        cin >> k;
        s[i].resize(k);
        cin >> s[i];
        for (int &x : s[i]) x--;
    }
    vector<int> p(M);
    cin >> p;
    int ans = 0;
    rep(i, 0, 1 << N) {
        bool ok = true;
        rep(j, 0, M) {
            int cnt = 0;
            for (int k : s[j]) {
                if (i >> k & 1) {
                    cnt++;
                }
            }
            if (cnt % 2 != p[j]) {
                ok = false;
            }
        }
        if (ok) ans++;
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
A,B,C,D=map(int,input().split())
dp=[[0]*(D+1) for i in range(C+1)]
m=998244353
dp[A][B]=1
for i in range(C-A):
    dp[A+i+1][B]=dp[A+i][B]*B%m
for j in range(D-B):
    dp[A][B+j+1]=dp[A][B+j]*A%m
for i in range(C-A):
    for j in range(D-B):
        dp[A+i+1][B+j+1]=(dp[A+i][B+j+1]*(B+j+1)+dp[A+i+1][B+j]*(A+i+1)-dp[A+i][B+j]*(A+i)*(B+j))%m
print(dp[-1][-1])

Measured memory_bytes: 133800
#include <stdio.h>
#include <stdlib.h>

#define N 10000
#define Q 500

int main() {
    
    int n, q, i, j, array_n[N], array_q[Q], cnt=0, tmp[Q], k, flg;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%d", &array_n[i]);
    }
    
    scanf("%d", &q);
    
    for (i = 0; i < q; i++) {
        scanf("%d", &array_q[i]);
    }
    
    for (i = 0; i < n; i++) {
        for (j = 0; j < q; j++) {
            if (array_n[i] == array_q[j]) {
                flg = 1;
                for (k = 0; k < cnt; k++) {
                    if (array_q[j] == tmp[k]) flg = 0;
                }
                if (flg) {
                    tmp[cnt] = array_q[j];
                    cnt++; 
                }
            }
        }
    }
    
    printf("%d\n", cnt);
    
    return 0;
}



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

int main(void){
  string s[3];
  for(int i = 0; i < 3; i ++){
    cin >> s[i];
  	cout << s[i].front();
  }
  
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int a, b;
  bool flag2 = false;
  while (cin >> a >> b) {
    if (a == 0 && b == 0) break;
    if (flag2) cout << endl;
    flag2 = true;

    bool flag = false;
    for (int i = a; i <= b; i++) {
      if (i % 400 == 0 || i % 100 && i % 4 == 0) {
        cout << i << endl;
        flag = true;
      }
    }
    if (!flag) cout << "NA" << endl;
  }

  return 0;
}

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

int main(){
    ll n,m,p[100005],cnt[100005],x,ac=0,pen=0;
    string s;
    cin>>n>>m;
    rep(i,n+1){
        p[i]=0;
        cnt[i]=0;
    }
    rep(i,m){
        cin>>x>>s;
        if(s[0]=='W'&&p[x]==0){
            cnt[x]++;
        }
        if(s[0]=='A'&&p[x]==0){
            p[x]=1;
            ac++;
            pen+=cnt[x];
        }
    }
    cout<<ac<<" "<<pen;

}

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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(),(x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
#define INF (1e9)

typedef pair<int,int> P;
typedef vector<int> vi;

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

int N;

signed main() {
    cin>>N;


    map<int,int> res;
    rep(i,1,N+1) {
        int n=i;
        if(i==1) {
            res[1]=1;
            continue;
        }

        for(int i=2,_n=n;i*i<=_n;i++) {
            while(n%i==0) {
                res[i]++;
                n/=i;
            }
        }
        if(n!=1) res[n]++;
    }

    vi prime;
    rep(i,1,N+1) {
        if(is_prime(i)) {
            prime.pb(i);
        }
    }
   
    int ans=0,ctn=0;
    rep(i,0,prime.size()) {
        if(res[prime[i]]>=74) ans++;
        rep(j,0,prime.size()) {
            if(i==j) continue;
            if(res[prime[i]]>=4 and res[prime[j]]>=14) ans++;
            if(res[prime[i]]>=2 and res[prime[j]]>= 24) ans++;

            rep(k,0,prime.size()) {
                if(j==k or k==i) continue;

                if(res[prime[i]]>=2 and res[prime[j]]>=4 and res[prime[k]]>=4) {
                    ans++;
                    ctn++;

                }
            }
        }
    }

    cout<<ans-ctn/2<<endl;
    return 0;
}





Measured memory_bytes: 256
#include<iostream>

#define     MAX_N_NUMBER     (100)

using namespace std;

int main(){
	const double rate = 0.05;
	const int init_money = 100000;
	int n,i,money;
	double buf;

	// 入力
	cin >> n;

	// 入力値のチェック
	if((n <= 0) || (n > ((int)(MAX_N_NUMBER)))){
		cerr << "Error!!" << endl;
		return 0;
	}

	// 倍々ゲーム
	money = init_money;
	for(i=1;i<=n;i++){
		buf = money * (1 + rate);
		money = (int)buf;
		money += 999;
		money /= 1000;
		money *= 1000;
	}

	// 出力
	cout << money << endl;

	return 0;
}

Measured memory_bytes: 1160
n, k = map(int, input().split())
a_s = list(map(int, input().split()))
dp = ["Second"] * (k + 1)
for i in range(k + 1):
    if dp[i] == "Second":
        for a in a_s:
            ii = i + a
            if ii > k:break
            dp[ii] = "First"
print(dp[-1])


Measured memory_bytes: 3828
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h> 
#include<cstring>

using namespace std;
int main(void){
    // Your code here!
   int n;
   cin >> n;
   int count = -1,end = 0;
   vector<int> vec(n);
   for(int i = 0; i < n; i++) cin >> vec.at(i);
   while(end == 0){
    count++;
    for(int i = 0; i < n; i++){
       if(vec.at(i) % 2 == 0){
               vec.at(i) /= 2;
        }
        else{
           end++;
           break;
        }
    }
   }
   cout << count << endl;
    
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define all(x) x.begin(),x.end()
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL);
#define N 502

int main(){
	FIO;
    ll x ; cin >> x;
	for(ll a = -N ; a <= N ; a++){
        for(ll b = -N ; b <= N ; b++){
            if(a*a*a*a*a - b*b*b*b*b == x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
	return 0;
}


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

int main(){
    int N;
    std::cin >> N;
    std::vector< int > A(N);
    int max = 0;
    for(int i=0; i<N; i++){
        std::cin >> A[i];
        if(A[i] > max){
            max = A[i];
        }
    }
    
    int near_half = 1e9;
    int near_half_dist = 1e9;
    for(int i=0; i<N; i++){
        if(A[i] == max){
            continue;
        }
        int dist = A[i] * 2 > max ? A[i] * 2 - max : max - A[i] * 2;
        if(near_half_dist > dist){
            near_half = A[i];
            near_half_dist = dist;
        }
    }
    
    std::cout << max << " " << near_half << std::endl;
    
    
    return 0;
}



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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int n, m, p, a, b;
vector<int> t;
using P = pair<int, int>;
vector<vector<P>> G;
double dp[1 << 8][30];
double dfs(int S, int v) {
    if (v == b) return 0;
    if (dp[S][v] != -1) return dp[S][v];
    double ret = 1e8;

    for (auto p : G[v]) {
        int u = p.first;
        int d = p.second;
        rep(i, n) if (!(S >> i & 1)) {
            ret = min(ret, dfs(S | 1 << i, u) + 1.0 * d / t[i]);
        }
    }
    return dp[S][v] = ret;
}
int main() {
    while (cin >> n >> m >> p >> a >> b, n) {
        rep(i, 1 << 8) rep(j, 30) dp[i][j] = -1;
        a--, b--;
        t.resize(n);
        rep(i, n) cin >> t[i];
        G.resize(m);
        rep(i, p) {
            int x, y, z;
            cin >> x >> y >> z;
            x--, y--;
            G[x].push_back(P(y, z));
            G[y].push_back(P(x, z));
        }
        double ans = dfs(0, a);
        if (ans == 1e8)
            cout << "Impossible" << endl;
        else
            printf("%.20f\n", ans);
        t.clear();
        G.clear();
    }

    return 0;
}

Measured memory_bytes: 3216
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	vector<int> n(b);
	vector<int> q(b);
	rep(i, b) {
		cin >> n[i];
	}
	int ans = 0;
	rep(i, a) {
		int sub = 0;
		rep(j, b) {
			cin >> q[j];
			sub += n[j] * q[j];
		}
		sub += c;
		if (sub > 0) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}
//Ctrl+Aを使わない

Measured memory_bytes: 256
#include<iostream>
int main(){
  int f[2],i,j;
  std::string r,a;
  while(std::cin>>r>>a,r!="0"&&a!="0"){
    for(f[0]=f[1]=i=0;i<4;i++)for(j=4;j-->0;)if(a[i]==r[j])f[i!=j]++;
    printf("%d %d\n",f[0],f[1]);
  }
}

Measured memory_bytes: 0
#if defined(_WIN32)
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

using ulong = unsigned long;
using ll = long long;
using ull = unsigned long long;

#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)

using namespace std;

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

	ll n, h;
	cin >> n >> h;

	ll aMax = 0;
	multiset<ll> b;
	REP(i, n)
	{
		ll a_, b_;
		cin >> a_ >> b_;
		aMax = max(aMax, a_);
		b.insert(b_);
	}

	ll cnt = 0;
	for(auto it = b.rbegin(); it != b.rend(); ++it)
	{
		if (*it < aMax) continue;
		h -= *it;
		cnt++;
		if (h <= 0)
		{
			cout << cnt;
			return 0;
		}
	}

	cnt += h / aMax;
	if (h % aMax != 0) cnt++;
	cout << cnt;
	return 0;
}


Measured memory_bytes: 4992
import java.io.IOException;
import java.util.Scanner;
public class Main {
    public static void main (String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        StringBuffer sb = new StringBuffer();
        int[][][] r = new int[4][3][10];
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
        	int b =sc.nextInt() - 1;
        	int c =sc.nextInt() - 1;
        	int d =sc.nextInt() - 1;
        	int e =sc.nextInt();
            r[b][c][d] += e;
        }
        for (int i = 0; i < 4; ++i) {
            if (i != 0) {
                System.out.println("####################");
            }
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 10; k++) {
                    System.out.print(" " + r[i][j][k]);
                }
                System.out.println();
            }
        }
        }


    }

Measured memory_bytes: 30124
N = int(input())
S = [input() for _ in range(N)]

AB_cnt = 0
c1 = 0
c2 = 0
c3 = 0


for s in S:
    AB_cnt += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        c1 += 1
    elif s[0] == 'B':
        c2 += 1
    elif s[-1] == 'A':
        c3 += 1
if c1 == 0:
    print(AB_cnt + min(c2,c3))
elif c2 + c3 > 0:
    print(AB_cnt + c1 + min(c2,c3))
else:
    print(AB_cnt + c1 - 1)

Measured memory_bytes: 9784
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=100010;
int n,m,a[maxn];
int calc(int l,int r,int x)
{return max(l,min(r,x));}
int main(){
	int X;
	scanf("%d%d",&X,&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int L=0,R=X;//初值……习惯 
	int t=0,k=0,s=-1,x=0;
	int time,A;
	scanf("%d",&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&time,&A);
		while(k<n&&a[k+1]<=time){
			int dif=s*(a[k+1]-t);
			L=calc(0,X,L+dif);
			R=calc(0,X,R+dif);
			s*=-1;
			x+=dif;
			t=a[k+1];
			k++;
		}//printf("\nL=%d R=%d\n",L,R);
		//printf("\nk=%d\n",k);
		int T=time-t;
		A=calc(L,R,A+x);
		//printf("\nA=%d\n",A);
		A=calc(0,X,A+s*T);
		printf("%d\n",A);
	}
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX=50;
int main()
{
  int n,m,q,qq,ii,j,t,res=0;
  int a[N_MAX][4],i[N_MAX];
  cin >> n >> m >> q;
  fill(i,i+n,1);
  for(qq=0;qq<q;qq++)
    for(j=0;j<4;j++)
      cin >> a[qq][j];
  for(qq=0;qq<q;qq++)
    if(i[a[qq][1]-1]-i[a[qq][0]-1]==a[qq][2])
      res+=a[qq][3];
  while(true){
    for(ii=n-1;ii>=0;ii--)
      if(i[ii]<m){
        i[ii]++;
        break;
      }
    if(ii<0) break;
    if(ii<n-1)
      fill(i+ii+1,i+n,i[ii]);
    t=0;
    for(qq=0;qq<q;qq++)
      if(i[a[qq][1]-1]-i[a[qq][0]-1]==a[qq][2])
        t+=a[qq][3];
    res=max(res,t);
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;
int main(void)
{
	int a, b; cin >> a >> b;
	int c; cin >> c;
	if (c == 0)
	{
		cout << 0 << "\n";
		return 0;
	}
	vector<int>arr(1001, 0);
	for (int i = 0; i < c; i++)
	{
		int aa, cc; cin >> aa >> cc;
		if (aa ==a && cc ==b)
		{
			cout << 1 << "\n";
			return 0;
		}
		for (int j = aa; j < cc + 1; j++)
		{
			arr[j] = 1;
		}
	}
	if (b-a == 1 && arr[a] == 1 && arr[b] == 1)
	{
		cout << "1" << "\n";
		return 0;
	}
	for (int i = a + 1; i < b; i++)
	{
		if (arr[i] == 1)
		{
			cout << 1 << "\n";
			return 0;
		}
	}
	cout << 0 << "\n";
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MOD 1000000007
 
using namespace std;
 
int main() {
    ll a,b,c; cin >> a >> b >> c;
    if(c-a-b > 0 and 4*a*b < (c-a-b)*(c-a-b)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    int A, B, X;
    char S[2];
    string ans;
    cin >> S;
    if(S[0] != S[1] && S[1] != S[2] && S[2] != S[0]) {
        ans = "Yes";
    } else {
        ans = "No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int n;cin>>n;
  vi p(n);
  rep(i,n) cin>>p.at(i);
  int ans=0;
  for(int i=1;i<n-1;i++){
    if(p[i]>p[i-1] && p[i]<p[i+1]) ans++;
    if(p[i]<p[i-1] && p[i]>p[i+1]) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256