akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
long long a, b, x, a5, b5;
int main() {
    DAU
    cin >> x;
    for (a = 1; a <= 7000; ++a) {
        a5 = a * a * a * a * a;
            for (b = 0; b <= a; ++b) {
                b5 = b * b * b * b * b;
                if (a5 - b5 == x) {
                    cout << a << ' ' << b;
                    PLEC
                }
                if (a5 + b5 == x) {
                    cout << a << ' ' << -b;
                    PLEC
                }
            }
    }
    PLEC
}


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

vector<bool> seen, finished;

int pos = -1;
stack<int> hist;

void dfs(const Graph &G, int v, int p) {
  seen[v] = true;
  hist.push(v);
  for (auto next_v : G[v]) {
    if (next_v == p || finished.at(next_v)) {
      continue;
    } else {
      if (seen.at(next_v) && !finished.at(next_v)) {
        pos = next_v;
        return;
      } else {
        dfs(G, next_v, v);
        if (pos != -1) {
          return;
        }
      }
    }
  }
  hist.pop();
  finished.at(v) = true;
}

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

  Graph G(N);
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  seen.assign(N, false);
  finished.assign(N, false);
  dfs(G, 0, -1);

  set<int> cycle;
  while (!hist.empty()) {
    int t = hist.top();
    cycle.insert(t);
    hist.pop();
    if (t == pos) {
      break;
    }
  }

  int Q;
  cin >> Q;
  rep(i, Q) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (cycle.count(a) && cycle.count(b)) {
      cout << 2 << endl;
    } else {
      cout << 1 << endl;
    }
  }
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;

int main(void){

	
	int N; cin >> N;
	set<string> st;

	REP(i,N){
		string S; cin >> S;
		st.insert(S);
	}

	cout << st.size() << endl;

	return 0;

}


Measured memory_bytes: 19224
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    vector<ll> b(1, 0);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        b.push_back(b.back() + a[i]);
    }
    ll ans = 0;
    map<ll, ll> p;
    for (auto j : b)
    {
        p[j % m]++;
    }
    for (auto y : p)
    {
        if (y.second > 1)
        {
            ans += y.second * (y.second - 1) / 2;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 5748
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

#define div 1000000007
//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

bool odd_even(int num){
    bool judge;
    if(num % 2){
        judge = true;
    }else{
        judge = false;
    }
    return judge;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    int a[n];
    rep(i, n)   cin >> a[i];
    
    int array[n];
    rep(i, n)   array[i] = 0;
    //printArray(array, n);
    rep(i, n){
        array[a[i]]++;
    }
    bool judge = odd_even(n);
    bool judge2 = true;
    
    //printArray(array, n);
    
    //奇数
    if(judge){
        if(array[0] != 1)   judge2 = false;
        for(int i = 2; i < n; i += 2){
            if(array[i] != 2)   judge2 = false;
        }
    }else{//偶数
        for(int i = 1; i < n; i += 2){
            if(array[i] != 2)   judge2 = false;
        }
    }
    
    int degree = n / 2;
    if(judge2){
        int res = 1;
        if(degree){
            rep(i, degree){
                res = (res * 2) % div;
            }
        }
        cout << res << endl;
    }else{
        cout << 0 << endl;
    }
    
}

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int N = 205;

int x, n;
int A[N];
bool cnt[N];

int main() {
    
    scanf("%d %d", &x, &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &A[i]);
        cnt[A[i]] = true;
    }
    
    for (int i = 0; i <= x; i++) {
        if (!cnt[x - i]) {
            printf("%d\n", x - i);
            return 0;
        }
        if (!cnt[x + i]) {
            printf("%d\n", x + i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3812
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def LIR(n): return [LI() for i in range(n)]
def MI(): return map(int, input().split())

#1
#1_A
"""
x,y,s,t = map(float, input().split())
a = int(input())
s-=x
t-=y
while a:
    a -= 1
    p,q = map(float, input().split())
    p-=x
    q-=y
    ans_x = s*(q*t+p*s)/(t*t+s*s)
    ans_y = t*(q*t+p*s)/(t*t+s*s)
    print(x+ans_x, y+ans_y)
"""

#2_A
p1x,p1y,c,d = MI()
q = II()
if p1x == c:
    f = 0
elif p1y == d:
    f = 1
else:
    f = 2
    m = (d-p1y)/(c-p1x)
for _ in range(q):
    px,py = MI()
    if not f:
        a = 2*p1x-px
        b = py
    elif f == 1:
        a = px
        b = 2*p1y-py
    else:
        a = (2*py+(1/m-m)*px+2*m*p1x-2*p1y)/(m+1/m)
        b = -1/m*(a-px)+py
    print(a,b)



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

using namespace std;

int main (void) {
    int N;
    cin >> N;

    int n_ac = 0;
    int n_wa = 0;
    int n_tle = 0;
    int n_re = 0;

    for ( int i = 0; i < N; i++ ) {
        string s;
        cin >> s;
        if ( s == "AC" )
            n_ac++;
        else if ( s == "WA" )
            n_wa++;
        else if ( s == "TLE" )
            n_tle++;
        else if ( s == "RE" )
            n_re++;
        else
            assert(false);
    }

    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",
            n_ac, n_wa, n_tle, n_re);
    return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;
}

Measured memory_bytes: 256
a, b, c, d, e, f = map(int, input().split())

def func(ans1,sugar):
    if sugar == 0:
        return 0
    else:
        ans = sugar * 100 / ans1
        return ans

sugar = 0
ans1 = 100 * a
max_a = f // (a * 100)

#操作１
for i in range(1, max_a + 1):
    max_b = (f - 100 * i * a) // (100 * b)
    #操作２
    for j in range(max_b +1):
        water = 100 * a * i + 100 * b * j
        #可能な砂糖の量
        max_sugar = (a * i + b * j) * e
        #最大濃度に近い
        if water + max_sugar <= f:
            max_c = max_sugar // c
            for k in range(max_c + 1):
                max_d = (max_sugar - k * c) // d
                if func(ans1, sugar) < func(water + (k * c + max_d * d) , (k * c + max_d * d)):
                    sugar = (k * c + max_d * d)
                    ans1 = water + sugar
        #濃度を薄める
        else:
            max_sugar = f - water
            min_sugar = c
            if min_sugar <= e:
                for k in range(e // min_sugar + 1):
                    max_d = (max_sugar - k * c) // d
                    if func(ans1, sugar) < func(water + (k * c + max_d * d), (k * c + max_d * d)):
                        sugar = (k * c + max_d * d)
                        ans1 = water + sugar

print(ans1,sugar)

Measured memory_bytes: 3064
S=input()
cnt_1=0
cnt_2=0
N=len(S)
if N%2==0:
	for i in range(N):
		if i%2==0:
			if S[i]=='1':
				cnt_1+=1
		else:
			if S[i]=='1':
				cnt_2+=1
	print(min(cnt_1+((N//2)-cnt_2),((N//2)-cnt_1)+cnt_2))
else:
	for i in range(N):
		if i%2==0:
			if S[i]=='1':
				cnt_1+=1
		else:
			if S[i]=='1':
				cnt_2+=1
	print(min(cnt_1+((N//2)-cnt_2),((N//2)+1-cnt_1)+cnt_2))

Measured memory_bytes: 3188
def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

def output(ans):
    print("Yes")
    size = len(ans)
    for i in range(size):
        if i == size-1:
            print(ans[i])
        else:
            print(ans[i], end=' ')

n = NextInt()
a = NextIntList()
b = NextIntList()[::-1]


def solve():
    border = n-1
    for i in range(n):
        if(a[i] >= b[i]):
            border = i
            break
    if a[border] != b[border]:
        output(b)
        return
    key = a[border]
    if a.count(key)+b.count(key) > n:
        print("No")
        return
    cnt = a[:border].count(key) + b[:border].count(key)

    for i in range(border, n):
        if a[i] != key or b[i] != key:
            output(b[i-1::-1] + b[:i-1:-1])
            return
        cnt += 2
        if cnt == i+1:
            output(b[i::-1] + b[:i:-1])
            return
    output(b[::-1])

solve()

Measured memory_bytes: 41968
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll cntdiv(ll i, ll d){
    ll cntd = 0;
    while(i%100 == 0){
        i /= 100;
        cntd++;
    }
    return cntd;
}

void solve(){
    ll d, n; cin >> d >> n;
    ll res;
    ll cnt = 0, i=1;
    while(true){
        ll j = i;
        ll cntd = cntdiv(j, d);
        if(cntd == d){
            cnt++;
        }
        if(cnt == n){
            res = i;
            break;
        }
        i++;
    }
    cout << res << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #pragma GCC optimization ("O3,unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
using namespace std;

#define _ << ": " <<
#define watch1(var1) (cerr << (#var1) _ var1 << '\n')
#define watch2(var1, var2) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << '\n'
#define watch3(var1, var2, var3) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << ", " << (#var3) _ var3 << '\n'
#define wloop(size, arr) cerr << (#arr) << ": "; for (int i = 0; i < size; i++) cerr << arr[i] << " \n"[i+1 == size]

template<typename... Args>
void read(Args&... args) { ((cin >> args), ...); }

template<typename... Args>
void show(Args... args) { ((cout << args << " "), ...); }

#define ints(a...) int a; read(a)
#define longs(a...) int64_t a; read(a)
#define IN(a) for (auto &it : a) cin >> it

void solve() {
    vector<int> v(5); IN(v);
    for (int i = 0; i < 5; i++) if (v[i] == 0) {
        show(i + 1);
        break;
    }
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1; 
    // cin >> T;
    while (T--) solve();
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int mina=1e9;
    mina=min(a+b,mina);
    mina=min(b+c,mina);
    mina=min(a+c,mina);
    cout<<mina;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

double y,v;

int main()
{
    while ( scanf( "%lf\n", &v ) != EOF )
    {
        y = v * v / 4 / 4.9;;
        int f = 1,h = 0;
        while( h < y )
        {
            f++;
            h += 5;
        }
        printf( "%d\n", f );
    }
    return 0;
}
/* 比較演算子に型の統一は不要。 */


Measured memory_bytes: 2700
// https://atcoder.jp/contests/abc159/tasks/abc159_e
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S;
    for (int i = 0; i < H; ++i)
    {
        string str;
        cin >> str;
        S.push_back(str);
    }

    int ans = H * W; // 分割回数の最小値
    // 横方向の割り方 2^(H - 1) 通りを全探索(bit探索)
    for (int bit = 0; bit < (1 << (H - 1)); ++bit)
    {
        // bit の各桁に応じてグループ分け
        vector<int> groupid(H, 0);
        int totalgroup = 1; // グループの総数
        for (int i = 0; i < H - 1; ++i)
        {
            if (bit & (1 << i))
            {
                // 1 の場合: 分割線を入れるので別グループとして通し番号を入れる
                groupid[i + 1] = groupid[i] + 1;
                ++totalgroup;
            }
            else
            {
                // 0 の場合: 同じグループに属しているので通し番号も同じ
                groupid[i + 1] = groupid[i];
            }
            
        }

        int totalline = totalgroup - 1; // 現在の試行における分割回数
        bool update = true; // 最小値の候補かどうか
        vector<int> whitenum(totalgroup, 0);
        // 縦方向の分割をなるべく少なくする
        // すなわち、 K を超える手前で線を入れる
        int add = 0;
        for (int x = 0; x < W; ++x)
        {
            bool nextstep = true;
            vector<int> cur(totalgroup, 0);
            for (int y = 0; y < H; ++y)
            {
                cur[groupid[y]] += S[y][x] - '0';
                whitenum[groupid[y]] += S[y][x] - '0';
                if (cur[groupid[y]] > K)
                {
                    // 試行している横方向の分割ではそもそも K を超えてしまうので不可
                    update = false;
                }

                if (whitenum[groupid[y]] > K)
                {
                    // これ以上分割を考える必要がない
                    nextstep = false;
                }

            }

            if (!nextstep)
            {
                ++totalline;
                whitenum = std::move(cur);
            }
        }
        if (update) ans = std::min(ans, totalline);
    }
    cout << ans << endl;
    return 0;
}


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

void Main() {
    // input
    u_int32_t N, K;
    cin >> N >> K;

    double S[N+1];
    S[0] = 0;
    for (u_int32_t i = 1; i <= N; i++) {
        u_int32_t p;
        cin >> p;
        // cout << "p: " << p << endl;
        S[i] = S[i-1] + (1.0 + p)/2; 
        // cout << "S: "<< S[i] << endl;
    }

    vector<double> diff(N-K+1);
    for (u_int32_t i = 0; i + K <= N; i++) {
        diff[i] = S[i+K] - S[i];
        // cout << "d: " << diff[i] << endl;
    }

    sort(diff.begin(), diff.end(), greater<double>());

    // output
    cout << diff[0] << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 6180
nk=input().split(" ")
N=int(nk[0])
K=int(nk[1])
p=input().split(" ")
p=[int(s)+1 for s in p]

max_sum=0
cur_sum=0
for i in range(K):
  cur_sum+=p[i]
max_sum=cur_sum
for i in range(1,N-K+1):
  cur_sum+=p[i-1+K]-p[i-1]
  max_sum=max(max_sum,cur_sum)
print(max_sum/2.0)

Measured memory_bytes: 25188
#include <iostream>
#include <cmath>
#define INF 1000000000
using namespace std;

int main() {
	int n,r[200000],mi[200000],ma[200000] = {},res = -INF;
	cin >> n;
	cin >> r[0];
	mi[0] = r[0];
	for(int i = 1;i < n;i++) {
		cin >> r[i];
		mi[i] = min(mi[i - 1],r[i]);
	}
	ma[n - 1] = r[n - 1];
	for(int i = n - 2;i >= 0;i--){
		ma[i] = max(ma[i + 1],r[i]);
	}
	for(int i = 0;i < n - 1;i++){
		res = max(res,ma[i + 1] - mi[i]);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 5456
var
  num,b,d,n,i,j,k,t:word;
  c,w,p,f:array[0..100000]of word;
  a:array[0..1000,0..100010]of word; 
  inp,m,v:longint;
begin
  readln(d,inp);
  m:=inp div 100;
  v:=m;
  t:=d;
  for i:=1 to d do
    begin
	  readln(num,inp);
	  b:=inp div 100;
	  for j:=1 to num do
	    begin
		  inc(n);
		  if j<>num then w[n]:=i*j else w[n]:=i*j+b;
		  c[n]:=j;
	      p[n]:=i;
		end;
	end;
  for i:=1 to n do
    begin
	  inc(a[p[i],0]);
	  a[p[i],a[p[i],0]]:=i;
	end;
  for i:=1 to t do
    for j:=v downto 0 do
	  for k:=1 to a[i,0] do
	    if j>=c[a[i,k]] then
		  if f[j]<f[j-c[a[i,k]]]+w[a[i,k]] then
		    f[j]:=f[j-c[a[i,k]]]+w[a[i,k]];
  for i:=1 to n do
    if f[i]>=m then break;
  write(i);
end.

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

if __name__ == '__main__':
    count = int(input())
    colorStr = input()
    res = 0
    for p in colorStr:
        if(p == 'R'):
            res = res + 1
        elif(p == 'B'):
            res =res -1
        else:
            break

    if (res > 0):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;



int main() {
  int N; cin>>N;
  vector<pint> p(N+2);
  REP(i,N) {
    int	v;
    cin>>v;
    p[i+1] = make_pair(v,	i);
  }
  p[0] = make_pair(-1, N+10);
  p[N+1] = make_pair(N+10, -1);
  sort(p.begin(), p.end());
  //  REP(i,p.size()) cout << p[i].first << "," << p[i].second << endl;                 
  int ans = 0;
  int tmp = 0;
  for(int i = 1; i < p.size(); i++) {
    if(p[i].second > p[i-1].second) {
      tmp++;
    } else {
      ans = max(ans, tmp);
      //      cout << i << " " << tmp << " " << ans << endl;                            
      tmp = 0;
    }
  }
  ans = max(ans, tmp);
  ans++;
  ans = N - ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;

int main(){
	int H,W,N;
	scanf("%d%d%d",&H,&W,&N);
	int ans=N/max(H,W)+(N%max(H,W)!=0);
	cout<<ans;
}

Measured memory_bytes: 256
# time complexity: O(|S - T|*|T|)
# space complexity: O(|S - T|)

S_d = input()
T = input()
len_T = len(T)


def replacable(string, T):
    for char_s, char_t in zip(string, T):
        if char_s == char_t or char_s == '?':
            continue
        else:
            return False
    else:
        return True


# see if S_d can contain T
t_start_index_list = []
# O(|S - T|)
for start_idx in range(len(S_d) - len_T + 1):
    string = S_d[start_idx:start_idx + len_T]
    # O(|T|)
    if replacable(string, T):
        t_start_index_list.append(start_idx)

if len(t_start_index_list) == 0:
    print("UNRESTORABLE")
else:
    S_candidate_list = []
    for t_start_index in t_start_index_list:
        S = S_d[:t_start_index] + T + S_d[t_start_index + len_T:]
        S = S.replace('?', 'a')
        S_candidate_list.append(S)
    S_candidate_list.sort()
    print(S_candidate_list[0])


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

#define se second
#define fi first
#define mk(a,b) make_pair(a,b)

typedef pair<int,int> pii;

int N;
string s1,s2;
int A[2010],B[2010];
int L[2010],R[2010];
int cmp[2010] = {0};
int INF = 1001001001;
bool F1 = false,F2 = false;

int CMP(int i)
{
    if(i < 0)return 0;
    return cmp[i];
}

int main()
{
    cin >> s1 >> s2;
    N = s1.size();
    for(int i = 0; i < N; i++)
    {
        A[i] = s1[i] - '0';
        B[i] = s2[i] - '0';
        if(A[i] == 1)F1 = true;
        if(B[i] == 1)F2 = true;
    }

    if(!F2)
    {
        if(F1)printf("-1\n");
        else printf("0\n");
        return 0;
    }

    for(int i = 0; i < N; i++)cmp[i] = (B[i] == 1) + cmp[i - 1];
    for(int i = 0; i < N; i++)L[i] = R[i] = INF;
    int mem = INF;
    int id = 1;
    for(int i = 0; i <= 2 * N; i++)
    {
        if(B[id] == 1)mem = 0;
        L[id] = min(L[id],mem);
        mem++;
        id++;
        id %= N;
    }
    mem = INF;
    id = 1;
    for(int i = 0; i <= 2 * N; i++)
    {
        if(B[id] == 1)mem = 0;
        R[id] = min(R[id],mem);
        mem++;
        id--;
        id = (id + N) % N;
    }

    int ans = INF;
    for(int i = -N + 1; i <= 0; i++)
    {
        int res = -i;
        vector<pii> V;
        for(int j = 0; j < N; j++)
        {
            int l = (j + i + N) % N,r = j;
            if(B[l] == A[r])
            {
                continue;
            }
            res++;
            if(l <= r && 0 < CMP(r) - CMP(l - 1))
            {
                continue;
            }
            if(l > r && (0 < CMP(r) - CMP(-1) || 0 < CMP(N - 1) - CMP(l - 1)))
            {
                continue;
            }
            V.push_back(mk(R[r],-L[l]));
        }
        int MIN = INF;
        if(V.size() == 0)MIN = 0;
        else
        {
            sort(V.begin(),V.end());
            for(int j = V.size() - 2; j >= 0; j--)V[j].se = min(V[j].se,V[j + 1].se);
            for(int j = 0; j < V.size() - 1; j++)MIN = min(MIN,V[j].fi - V[j + 1].se);
            MIN = min(MIN,min(-V[0].se,V.back().fi));
        }
        ans = min(ans,res + MIN * 2);
    }
    for(int i = 1; i < N; i++)
    {
        int res = i;
        vector<pii> V;
        for(int j = 0; j < N; j++)
        {
            int l = j,r = (j + i) % N;
            if(A[l] == B[r])
            {
                continue;
            }
            res++;
            if(l <= r && 0 < CMP(r) - CMP(l - 1))
            {
                continue;
            }
            if(l > r && (0 < CMP(r) - CMP(-1) || 0 < CMP(N - 1) - CMP(l - 1)))
            {
                continue;
            }
            V.push_back(mk(R[r],-L[l]));
        }
        int MIN = INF;
        if(V.size() == 0)MIN = 0;
        else
        {
            sort(V.begin(),V.end());
            for(int j = V.size() - 2; j >= 0; j--)V[j].se = min(V[j].se,V[j + 1].se);
            for(int j = 0; j < V.size() - 1; j++)MIN = min(MIN,V[j].fi - V[j + 1].se);
            MIN = min(MIN,min(-V[0].se,V.back().fi));
        }
        ans = min(ans,res + MIN * 2);
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

int main()
{
  int n;
  cin>>n;

  int check[2] = {0};
  int ans = 0;

  for(int i = 0;i < n;++i){
    char pa;
    int x;
    cin>>pa;
    cin>>x;

    if(pa == '('){
      check[0] += x;
    }
    else{
      check[1] += x;
      if(check[1] > check[0]){
        ans = 1;
      }
    }
  }
  if(check[1] != check[0]){
    ans = 1;
  }

  if(ans == 1){
    cout<<"NO"<<endl;
  }
  else{
    cout<<"YES"<<endl;
  }

  return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read()
{
	ll x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

const int maxn = 1e5 + 10;
int n, a[maxn], b[maxn];
int main()
{
	n = read();
	for (int i = 1; i <= n; i ++)
		a[i] = read(), b[i] = a[i];
	for (int i = 1; i <= n; i ++)
		if (a[i] & 1) return puts("first"), 0;
	puts("second"); return 0;
//	sort(b + 1, b + 1 + n);
//	for (int i = 2; i <= n; i ++)
//		b[i] -= b[i - 1];
	int ans = 0;
	for (int i = 1; i <= n; i ++)
		ans ^= a[i];
	if (ans & 1) puts("first");
	else puts("second");
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<ctime>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<tuple>
#include<cassert>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<iomanip>
#include<climits>
#include<typeinfo>
#include<utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
double pi = 3.141592653589793238;
using ll = long long;
using namespace std;

ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpcombination[10000][10000];
ll combination(ll n, ll r) {
	if (n == r) { return dpcombination[n][n] = 1; }
	else if (r == 0) { return dpcombination[n][0] = 1; }
	else if (r == 1) { return dpcombination[n][1] = n; }
	else if (dpcombination[n][r]) { return dpcombination[n][r]; }
	else { return dpcombination[n][r] = combination(n - 1, r - 1) + combination(n - 1, r); }
}

void clockman(int time1) {

	cout << 1.0*(clock() - time1) / CLOCKS_PER_SEC << endl;
	return;
}
//cout << fixed << setprecision(10)


int main()
{
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	double minu = 60 * h + m;
	double ans;
	double c;
	c = abs(minu/2-6*m);
	ans = sqrt(a*a + b * b - 2 * a*b*cos(c*pi/180));

	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}



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

int main() {
  int a, b, c;
  while (cin >> a >> b >> c) {
    bool used[100];
    memset(used, false, sizeof(used));

    used[a] = used[b] = used[c] = true;
    int sum = a + b;
    int cnt = 0;
    for (int i = 1; i <= 10; ++i) {
      if (used[i]) continue;
      if (sum + i <= 20) cnt++;
    }

    cout << (cnt > 7/2 ? "YES" : "NO") << endl;
  }
}

Measured memory_bytes: 3084
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
      
        BigDecimal A = new BigDecimal(in.next());
        BigDecimal B = new BigDecimal(in.next());
		BigDecimal a = A.multiply(B);
        long answer = a.longValue();
        System.out.println(answer);
    }
}

Measured memory_bytes: 35988
#include<iostream>
using namespace std;
int main(){
    int n, x;
    cin >> n;
    int a[n];
    for (int i=0; i < n; i++) {
        cin >> x; 
        a[i] = x;
    }
    for (int i=n-1; i > 0; i--) {
        cout << a[i] << " ";
    }
    cout << a[0] << endl;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x,y;
	cin >> n >> x >> y;
	 vector<vector<int>> data(n+1, vector<int>(n+1));
	 for (int i = 1; i < n+1; ++i)
	 {
	 	for (int j= 1; j < n+1; ++j)
	 	{
	 		data.at(i).at(j) = abs(j-i);
	 	
        }
	 }
	 vector<vector<int>> dis(n+1, vector<int>(n+1));
	 for (int i = 1; i < n+1; ++i)
	 {
	 	for (int j= 1; j < n+1; ++j)
	 	{
	 		if(i<=j){
	 		dis.at(i).at(j) = abs(x-i)+1+abs(j-y);
	 	}
	 	else{
	 		dis.at(i).at(j) = abs(x-j)+1+abs(i-y);

	 	}
	 	
        }
	 }
	 vector<vector<int>> answer(n+1, vector<int>(n+1));

  for(int i = 1; i<n+1;++i){
    for(int j=1;j<n+1;++j){
      answer.at(i).at(j)=min(data.at(i).at(j),dis.at(i).at(j));
    }
}

  vector<int> value(n+1);
	 for (int i = 1; i < n+1; ++i)
	 {
	 	for (int j= 1; j < n+1; ++j)
	 	{
	 		value.at(answer.at(i).at(j))++;
	 	}
	 }
	 for (int i = 1; i < n; ++i)
	 {
	 	cout << value.at(i)/2 << endl;
	 }
	
	}
	

Measured memory_bytes: 47360
#include <iostream>
using namespace std;
int main(){
    int n,m,a,b,i,citys[50]={0};
    cin >> n >> m;
    for(i = 0;i < m;i++){
        cin >> a >> b;
        citys[a-1]++;
        citys[b-1]++;
    }
    for(i = 0;i < n;i++){
        cout << citys[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<int,int> P;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return 1;
    }
    return 0;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return 1;
    }
    return 0;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

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


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;

int prime_cnt[1000];
void decompositPrime(int n){
    int a=2;

    while(n>=a*a){
        if(n%a==0){
            prime_cnt[a]++;
            n/=a;
        }else{
            a++;
        }
    }
    prime_cnt[n]++;
}

int main(){
    ll N;
    cin >> N;
    ll ans=0;
    vector<ll>cnt(N,0);
    Fill(prime_cnt,0);

    for(int i=2; i<=N; i++){
        decompositPrime(i);
    }
    // 75 = 3*5*5
    int cnt3=0;
    for(int i=2; i<=N; i++){
        if(prime_cnt[i]>=2) {
            cnt3++;
        }
    }

    int cnt5=0;
    for(int i=2; i<=N; i++){
        if(prime_cnt[i]>=4)
            cnt5++;
    }

    int cnt15=0;
    for(int i=2; i<=N; i++){
        if(prime_cnt[i]>=14)
            cnt15++;
    }

    int cnt25=0;
    for(int i=2; i<=N; i++){
        if(prime_cnt[i]>=24)
            cnt25++;
    }
    int cnt75=0;
    for(int i=2; i<=N; i++){
        if(prime_cnt[i]>=74)
            cnt75++;
    }

    ans+=(cnt3-2)*(cnt5*(cnt5-1))/2;
    ans+=cnt15*(cnt5-1);
    ans+=cnt25*(cnt3-1);
    ans+=cnt75;
    cout << ans <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  vector<vector<int>> c(m);
  rep (i, m) {
    cin >> a[i] >> b[i];
    c[i].resize(b[i]);
    rep (j, b[i]) {
      cin >> c[i][j];
      --c[i][j];
    }
  }
  vector<int> dp(1 << n, INT_MAX);
  unordered_set<int> next;
  vector<int> keybit(m);
  rep (i, m) {
    int bit = 0;
    rep (j, b[i]) bit |= 1 << c[i][j];
    keybit[i] = bit;
    dp[bit]   = min(dp[bit], a[i]);
    next.insert(bit);
  }
  while (!next.empty()) {
    auto now = next;
    next.clear();
    rep (i, m) {
      allrep (bit, now) {
        int newbit = bit | keybit[i];
        if (dp[bit] + a[i] < dp[newbit]) {
          dp[newbit] = dp[bit] + a[i];
          next.insert(newbit);
        }
      }
    }
  }
  cout << (dp.back() != INT_MAX ? dp.back() : -1) << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}

ll solve(vector<ll> a, vector<ll> b, ll k){
	ll ans = 0;
	vector<ll> dpA(a.size()), dpB(b.size());
	for(int i = 0; i < b.size(); i++){
		dpB[i] = b[i];
		if(i)
			dpB[i] += dpB[i - 1];
	}

	for(int i = 0; i < a.size(); i++){
		dpA[i] = a[i];
		if(i)
			dpA[i] += dpA[i - 1];
	}

	for(int i = 0; i < a.size(); i++){
		ll rem = k - dpA[i];

		if(rem < 0)
			break;

		ll cur = 1ll * i;
		ll lo = 0, hi = (ll)b.size() - 1, opt = -1;
		while(lo <= hi){
			ll mid = (lo + hi) >> 1;
			if(dpB[mid] <= rem){
				opt = mid;
				lo = mid + 1;
			}
			else hi = mid - 1;
		}

		assert(opt != -1);
		ans = max(ans, cur + opt);
	}

	return ans;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n, m;
	ll k;

	cin >> n >> m >> k;

	vector<ll> a(n + 1), b(m + 1);
	for(int i = 1; i <= n; i++)
		cin >> a[i];

	for(int i = 1; i <= m; i++)
		cin >> b[i];

	cout << max(solve(a, b, k), solve(b, a, k)) << endl;
	
	return 0;
}

Measured memory_bytes: 15724
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long X = scanner.nextLong();
		
		long sho1 = X / 500;
		long amari1 = X % 500;
		long sho2 = amari1 / 5;
		
		long happy = sho1 * 1000 + sho2 * 5;
		
		System.out.println(happy);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)

int main()
{
    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;


    A--;
    B--;
    C--;
    D--;

    string S,res;

    cin >> S;

    REP(i,N)
    {
        if(S[i] == '#' && i+1 < N)
        {
            if(S[i + 1] == '#' && A <= i && i <= C )
            {
                cout << "No" << endl;
                return 0;
            }
            if(S[i + 1] == '#' && B <= i && i <= D )
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    //
    if(C < D)
    {
        cout << "Yes" << endl;   
        return 0;
    }

    // C > D
    for(int i = B-1; i < D; i++)
    {
        if(S[i] == '.' && i+2 < N)
        {
            if(S[i+1] == '.' && S[i+2] == '.')
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;
const ld pi = (acos(-1));

ll lcm(ll a,ll b){
  ll g = __gcd(a,b);
  return a/g*b;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  ll a,b;
  cin >> a >> b;
  cout << lcm(a,b) << endl;
  

 }

Measured memory_bytes: 256
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                while(sc.hasNext()){
                        int[] l = new int[10];
                        String[] s = sc.nextLine().split(",");
                        int total = 0;
                        for(int i = 0; i < 10; i++){
                                l[i] = Integer.parseInt(s[i]);
                                total += l[i];
                        }   
                        int v = Integer.parseInt(s[10])+Integer.parseInt(s[11]);
                        double p = Integer.parseInt(s[10])*(double)total/v;
                        for(int i = 0; i < 10 && 0 < p; i++){
                                p -= l[i];
                                if(p <= 0){ 
                                        System.out.println(++i);
                                }   
                        }   
                }   
                sc.close();
        }   
}

Measured memory_bytes: 12000
import java.util.*;

public class Main {                        
  public static void main(String[] args) {   
     
   Scanner sc = new Scanner(System.in);                                                                                     
    
   boolean flag[] = {false,false,false,false,false,false,false,false};
   
    int N = sc.nextInt();
   
    int maxcnt = 0;
    
    for(int i = 0;i < N;i++){
       int a = sc.nextInt();
       
       for(int j = 0;j <= 7;j++){
           if(400*j <= a && a < 400*(j+1)){
               flag[j] = true;   
               break;
           }      
           if(3200 <= a){
               maxcnt++;
               break;
           }
       }                      
    }
    
    int sum = 0;
           
    for(int i = 0;i < 8;i++){
        if(flag[i] == true){
            sum++;
        }        
    }
    
    int min = 0;
    int max = 0;    
    
    if(sum == 0){
        min = 1;
        max = maxcnt;
        System.out.println(min + " " + max);
        return;
    }    
    
    if(sum > 0){
        min = sum;
        max = sum + maxcnt;
        System.out.println(min + " " + max);
        return;
    }    
    
  }             
}



Measured memory_bytes: 22996
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>

using namespace std;

int main()
{
    int N, A, B;
    int pass = 0, overseas = 0;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    
    for(int i=0; i<N; i++) {
        if (S[i] == 'a') {
            if (pass < A+B) {
                pass++;
                cout << "Yes" << endl;
            }
            else {
                cout << "No" << endl;
            }
        }
        else if (S[i] == 'b') {
            overseas++;
            if (pass < A+B && overseas <= B) {
                pass++;
                cout << "Yes" << endl;
            }
            else {
                cout << "No" << endl;
            }
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 896
import sys
import copy
import math
import string
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial

from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)


stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a = ni()
b = ni()
h = ni()
print((a + b) * h // 2)

Measured memory_bytes: 5144
import java.util.Scanner;

class Main {
    
    public static void main(String[] args){
	final int X = 0;
	final int Y = 1;
	int p[][] = new int[50][2];
	int times = 1;
	Scanner stdin = new Scanner(System.in);
	while(true){
	    int n = stdin.nextInt();
	    if(n == 0){
		break;
	    }
	    for(int i = 0; i < n; i++){
		p[i][X] = stdin.nextInt();
		p[i][Y] = stdin.nextInt();
	    }
	    double answer = 0;
	    for(int i = 0; i < n - 1; i++){
		answer += (double)(p[i + 1][X] - p[i][X]) * (p[i][Y] + p[i + 1][Y]) / 2;
	    }
	    answer += (double)(p[0][X] - p[n - 1][X]) * (p[n - 1][Y] + p[0][Y]) / 2;
	    System.out.printf("%d %.1f\n", times, answer);
	    times++;
	}
    }
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int N;
  while (cin >> N) {
    bool g[7][7] = {};
    bool wf[7][7] = {};
    for (int i = 0; i < N; ++i) {
      int v;
      cin >> v;
      int x = v/10, y = v%10;
      g[x][y] = wf[x][y] = true;
      g[y][x] = wf[y][x] = true;
    }
    for (int k = 0; k < 7; ++k)
      for (int i = 0; i < 7; ++i)
	for (int j = 0; j < 7; ++j)
	  if (wf[i][k] && wf[k][j])
	    wf[i][j] = true;

    int cnt[7] = {};
    int odd = 0;
    int use = 0;
    for (int i = 0; i < 7; ++i) {
      int adj = 0;
      for (int j = 0; j < 7; ++j) {
	if (i != j && g[i][j]) ++adj;
	if (wf[i][j]) ++cnt[i];
      }
      if (adj % 2 == 1) ++odd;
      if (adj > 0 || g[i][i]) ++use;
    }
    bool res = (odd == 0 || odd == 2);
    for (int i = 0; i < 7; ++i) {
      if (cnt[i] > 0 && cnt[i] != use) res = false;
    }
    cout << (res ? "Yes" : "No") << endl;
  }
}

Measured memory_bytes: 1152
#include <iostream>
    #include <stdio.h>
    #include <string>
    #include <math.h>
    #include<algorithm>
    #include <numeric>
    using namespace std;

     long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

    int main(){
      long long N,X;
      cin >> N >> X;
      long long x[N];
      for(long long i=0;i<N;i++){
       cin >> x[i]; 
      }
      long long ans=abs(x[0]-X);
      for(int i=0;i<N;i++){
       ans=GCD(ans,abs(x[i]-X)); 
      }
      cout << ans << endl;
      return 0;}

Measured memory_bytes: 1024
N, K = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
dp = [0]*N
dp[0] = sum(p[:K])
for i in range(N-K):
    dp[i+1] = dp[i] - p[i] + p[i+K]
index = dp.index(max(dp))
for i in range(index, index+K):
    ans += 0.5*p[i]*(p[i]+1)/p[i]
print(ans)


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

int main() {
    int n , k;
    cin >> n >> k;
    vector <int> p , m;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >>x;
        if(x >= 0) {
            p.push_back(x);
        }
        else
            m.push_back(-x);
    }
    sort((p).begin() , (p).end());
    sort((m).begin() , (m).end());
    int P = p.size();
    int M = m.size();
    int ans = 1000000000;
    for (int i = 0; i < k + 1; ++i) {
        int j = k - i;
        if(i > P || j > M) {
            continue;
        }
        int pd = 0;
        if(i) {
            pd = p[i - 1];
        }
        int md = 0;
        if(j) {
            md = m[j - 1];
        }
        ans = min(ans , 2 * min(pd , md) + max(pd , md));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int a,b; cin >> a >> b;
    cout << a*b-a-b+1 << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    string s;cin>>s;
    int sz=s.size();
    lint ans=0,tmp=0;
    for(int i=sz-1;i>=0;i--){
        if(s[i]=='C'&&i-1>=0){
            if(s[i-1]=='B'){
                tmp++;i--;
            }
            else tmp=0;
        }
        else if(s[i]=='A'){
            ans+=tmp;
        }
        else tmp=0;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3764
MOD = (10 ** 9) + 7

list_size = 1000000

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)

def power(n, x):
	if x == 1:
		return n
	elif x % 2 == 0:
		return power(int((n * n) % MOD), int(x / 2))
	else:
		return int((n * power(n, x - 1)) % MOD)

f_r_list[-1] = power(f_list[-1], MOD - 2)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % MOD)

def factorial(i):
	if i == 0:
		return 1
	else:
		return f_list[i-1]

def comb(n, r):
	if n < r:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD 

n = int(input())
ans = ((n - 1) * factorial(n - 1)) % MOD
for i in range(n - 2, (n + 1) // 2 - 1, -1):
	ans -= comb(i - 1, n - i - 1) * factorial(n - i - 1) * factorial(i)
	ans %= MOD
	#print(ans, cnt)
print(ans)

Measured memory_bytes: 82292
#include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    string a,b;
    cin>>a>>b;
    string h = "H";
    int ans = 1;
    if (b == h) ans = 1; else ans = -1;
    if (a == h) ans *= 1; else ans *= -1;
    if (ans > 0) cout<<"H"<<endl; else cout<<"D"<<endl;
}


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

int main(){
  
  int n,m;
  cin>>n>>m;
  int answer=0;
  vector<vector<int>> data(n,vector<int>(m,0));
  
  
  
  
  for (int i=0;i<n;i++){
    int size;
    cin>>size;
    
    for (int j=0;j<size;j++){
      int tmp;
      cin>>tmp;
      data.at(i).at(tmp-1)=1;
    }
  }
  
  for (int j=0;j<m;j++){
    int flag=1;
    for (int i=0;i<n;i++){
      if (data.at(i).at(j)==0){
        flag=0;
        break;
      }
    }
    answer+=flag;
  }
  
  cout<<answer<<endl;
  

}
  













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

using namespace std;

const int MAX_N = 20000;



int main(){
    
    
    int N;
    cin >> N;
    
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    int max1 = 0;
    int max2 = 0;
    
    for (int i = 0; i < N; i++) {
        if (max2 < A[i]) {
            max2 = A[i];
        }
        if (max1 < max2) {
            swap(max1, max2);
        }
    }
    
    for (int i = 0; i < N; i++) {
        if (max1 > A[i]) {
            cout << max1 << endl;
        }else{
            cout << max2 << endl;
        }
        
        
    }
        
        
        
        
    
    
    
    
}


Measured memory_bytes: 2432