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

int main() {
    constexpr ll MOD = 1000000007;
    constexpr ll MAX = 1 << 20;

    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    //累積XOR
    vector<ll> b(N + 1, 0);
    for (ll i = 0; i < N; i++) {
        b[i + 1] = b[i] ^ A[i];
    }

    //今いるマスに好きな整数をXとしている場合に累積XORがXとして到達する場合の数
    vector<ll> dp(MAX, 1);

    //今いるマスに好きな整数をXとしている場合に累積XORがXとして到達する場合の数の累積和
    vector<ll> dp_sum(MAX, 0);

    //累積XORが0になった回数
    ll zero_num = 0;

    //前回累積XORがXとなったときのzero_numの値
    vector<ll> last_zero_num(MAX, 0);

    for (ll i = 1; i < N; i++) {
        //累積XORがb[i]としてここに到着する場合の数を次の2通りに分けて計算
        //1) 前にb[i]として届くパターンの最後だけをここに入れ替え
        //   つまり以前のdp[b[i]]そのものなので(2)を+=で足せば良い
        //2) b[i]として到達する累積和と前回以降から0が出てきた数との掛け算
        (dp[b[i]] += dp_sum[b[i]] * (zero_num - last_zero_num[b[i]])) %= MOD;

        //累積和を計算しておく
        (dp_sum[b[i]] += dp[b[i]]) %= MOD;

        //b[i]となったときの0の出現回数を記録しておき差分を取れるようにする
        last_zero_num[b[i]] = zero_num;
        
        //0の出現回数を記録
        if (b[i] == 0) {
            zero_num++;
        }
    }

    if (b[N]) {
        //b[N]として遷移した先のものが答え
        cout << (dp[b[N]] + dp_sum[b[N]] * (zero_num - last_zero_num[b[N]])) % MOD << endl;
    } else {
        //X = 0の場合:累積XORが0になるところで仕切りを入れるか入れないか2通り
        ll ans = 1;
        for (ll i = 0; i < zero_num; i++) {
            (ans *= 2) %= MOD;
        }

        //X != 0の場合:Xで遷移してくる累積和の和
        for (ll X = 1; X < MAX; X++) {
            (ans += dp_sum[X]) %= MOD;
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 32640
import random
import time
import numpy as np

def decrease(day, schedule, c, s, satisfy):
    ret = 0
    date = [0] * 26

    for d in range(day):
        now = schedule[d] + 1
        date[now - 1] = d + 1
        tmp = 0
        for i in range(26):
            tmp += c[i] * (now - date[i])
        ret += tmp
        satisfy.append(tmp)

    return ret

def change(_from, _to, schedule, c, s, satisfy):
    ret = 0
    date = [0] * 26

    for d in range(_to):
        if d < _from:
            ret += satisfy[d]
            continue

        now = schedule[d] + 1
        date[now - 1] = d + 1
        tmp = 0
        for i in range(26):
            tmp += c[i] * (now - date[i])
        ret += tmp
        satisfy[d] = tmp

    return ret

def Main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(D)]
    
    dissatisfy=[]
    schedule = []
    score = 0
    start = time.time()

    #最大値を足すだけ
    for i in range(D):
        schedule.append(np.argmax(s[i]))
        score += np.max(s[i])
    
    ans = score - decrease(D, schedule, c, s, dissatisfy)
    
    while time.time() - start < 1.85:
        contest = random.randint(0, 25)
        day = random.randint(0, D - 1)
        if schedule[day] == contest:
            continue

        save = dissatisfy.copy()
        dec = change(day + 1, D, schedule, c, s, dissatisfy)
        score2 = score - s[day][schedule[day]] + s[day][contest]

        if ans < score2 - dec:
            ans = score2 - dec
            score = score2
            schedule[day] = contest
        else:
            dissatisfy = save
        
    for i in range(D):
        print(schedule[i] + 1)

if __name__ == "__main__":
    Main()

Measured memory_bytes: 27496
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
using namespace std;
#define INF 0x3f3f3f
int main()
{
    string s;
    cin >> s;
    int flag = 0;
    for(int i = 1; i < 4; i++){
        if(s[i] == s[i-1]){
            flag = 1;
            break;
        }
    }
    if(flag){
        cout << "Bad" << endl;
    }
    else cout << "Good" << endl;
    return 0;
}



Measured memory_bytes: 256
a = input()

for i in range(8):
    l = []
    for j in range(3):
        if i & (1 << j):
            l.append('+')
        else:
            l.append('-')
    s = ''
    l.append(' ')
    for p, q in zip(list(a), l):
        s += p + q
    if eval(s) == 7:
        print(s[:-1] + '=7')
        exit(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;

int gcd(int a, int b)
{
    int r;
    if (a < b) swap(a, b);

    while(b > 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
int main()
{
    int a, b;
    cin >> a >> b;
    int ans = gcd(a, b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <deque>
using namespace std;

int main () {
    string s;
    int m;
    int h;
    
    while(cin >> s) {
        if (s == "-") break;
        deque<char> data;
        cin >> m;
        for (int i = 0; i < s.size(); i++) {
            data.push_back(s[i]);
        }
        for (int i = 0; i < m; i++) {
            cin >> h;
            for (int j = 0; j < h; j++) {
                char data_ = data.front();
                data.pop_front();
                data.push_back(data_);
            }
        }
        for (int i = 0; i < data.size(); i++) {
            printf("%c", data[i]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 3152
str = list(input())
n = len(str)
max = 0
counter = [0,0,0]
for i in range(n):
  if 'A' in str[i] or 'T'in str[i] or 'C' in str[i]or 'G'in str[i]:
    counter.insert(i, counter[i] + 1)
  else:
    counter.append(0)
  

con = 0;    
for i in range(n+1):
  if counter[i] == 1:
    con += 1
    continue
  else :
    if con > max :
      max = con
      con = 0
    
print(max)

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

int main(){
  int H, W, count;
  string prev_row, row, next_row;
  cin >> H >> W >> next_row;
  for (int i=0; i<H; i++){
    prev_row = row; row = next_row;
    cin >> next_row;
    for(int j=0; j<W; j++){
      if(row.at(j) == '#') continue;
      count = 0;
      if(i >= 1){
        if(j-1 >= 0) if(prev_row.at(j-1) =='#') count++;
        if(prev_row.at(j) == '#')count++;
        if(j+1 < W) if(prev_row.at(j+1) == '#')count++;
      }
      if(j-1 >= 0) if(row.at(j-1) == '#') count++;
      if(j+1 <W) if(row.at(j+1) == '#' ) count++;
      if(i <= H-2){
        if(j-1 >= 0) if(next_row.at(j-1) =='#') count++;
        if(next_row.at(j) == '#')count++;
        if(j+1 < W) if(next_row.at(j+1) == '#')count++;
      }
      row.at(j) = to_string(count).at(0);
    }
    cout << row << endl;
  }
}

Measured memory_bytes: 256
# 頭から順にaに変えていく

import sys
readline = sys.stdin.readline

S = list(readline().rstrip())
K = int(readline())

z = ord("z")
for i in range(len(S) - 1):
  # aにするためのコストを求める
  if S[i] == "a":
    continue
  cost = z + 1 - ord(S[i])
  if cost <= K:
    S[i] = "a"
    K -= cost

K %= 26
nex = ord(S[-1]) + K
if nex > ord("z"):
  nex -= 26
S[-1] = chr(nex)

print("".join(S))


Measured memory_bytes: 4152
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int counter = 0;
    for (size_t i = 0; i <= n/r; i++)
    {
        for (size_t j = 0; j <= n/g; j++)
        {
            int z = (n-(i*r+j*g))/b;
            if(0<=z && z<=(n/b) && z*b+j*g+i*r==n) counter++;
        }
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int x, t;
	cin >> x >> t;
	int ans = x - t;
	if (ans < 0) ans = 0;
	cout << ans << endl;
}

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

public class Main {
    public static void main(String[] args) {
        int N, x;
        long[] a;
        Scanner in = new Scanner(System.in);
        N = in.nextInt();
        x = in.nextInt();
        a = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = in.nextInt();
        }
        long ans = solve(N, x, a);
        System.out.println(ans);
    }

    //a_i単体でxを超えていたらそこは絶対にいじる
    //a_i - (a_i - x) = x
    //1 6 1 2 0 4 (x=1)
    //1 1 1 1 0 1 (5+1+3で9回は絶対に操作する)
    //3 3 3 3 3 (x=1)
    //1 1 1 1 1 (2+2+2+2+2=10回は操作)
    //1 0 1 0 1 (10+2 = 12回が答え？)
    //3 5 3 1 3 6 2 (x=3)
    //3 3 3 1 3 3 2 (2+3=5回操作)
    //3 0 3 0 3 0 2 (3+1+3=7)
    //2 1 2 1 2 1 2 (1+2+1+1+2=7回)
    //1 2 1 1 2 1 2 (2+1+2+1+2=8回)
    //5 5 5 (x=0) -> 15
    //5 5 5 (x=1)
    //1 1 1 (4+4+4=12)
    //1 0 1 (12+1=13)
    //5 5 5 5 5
    //5 0 5 0 5
    //0 5 0 5 0
    //どっち?
    static long solve(int N, int x, long[] a) {
        long ans = 0;
        long[] b = Arrays.copyOf(a, a.length);
        for (int i = 0; i + 1 < N; i++) {
            b[i] = (b[i] > x ? x : b[i]);
            b[i + 1] = (b[i + 1] > x ? x : b[i + 1]);
            if (b[i] + b[i + 1] > x) {
                b[i + 1] = x - b[i];
            }
        }
        for (int i = 0; i < N; i++) {
            ans += a[i] - b[i];
        }
        return ans;
    }
}


Measured memory_bytes: 50664
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import deque

n = ni()
a = []
for _ in range(n):
    a.append(ni())
    
mx_cent = [ai for ai in a]
mn_cent = [ai for ai in a]    

a.sort()
a = deque(a)

mx_cent = deque([ai for ai in a])
mn_cent = deque([ai for ai in a])


bmx = deque([mx_cent.pop()])
bmn = deque([mn_cent.popleft()])

cnt = 0


while len(mx_cent) > 1:
    lf = 0
    rt = 0
    if cnt % 2 == 0:
        lf = mx_cent.popleft()
        rt = mx_cent.popleft()
    else:
        lf = mx_cent.pop()
        rt = mx_cent.pop()
    
    bmx.appendleft(lf)
    bmx.append(rt)
    
    
    if cnt % 2 == 0:
        lf = mn_cent.pop()
        rt = mn_cent.pop()
    else:
        lf = mn_cent.popleft()
        rt = mn_cent.popleft()
    
    bmn.appendleft(lf)
    bmn.append(rt)
    
    cnt += 1


if len(mx_cent) == 1:
    last = mx_cent.pop()
    if abs(bmx[0] - last) > abs(bmx[-1] - last):
        bmx.appendleft(last)
    else:
        bmx.append(last)
        
    last = mn_cent.pop()
    if abs(bmn[0] - last) > abs(bmn[-1] - last):
        bmn.appendleft(last)
    else:
        bmn.append(last)

diffmx, diffmn = 0, 0        
for i in range(n-1):
    diffmx += abs(bmx[i+1] - bmx[i])
    diffmn += abs(bmn[i+1] - bmn[i])
    
print(max(diffmx, diffmn))

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

using namespace std;

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

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

    cout << GCD(a, b) << endl;
    
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<cstdio>
#define MN 200000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,head[MN+5],c[MN+5],num,inq[MN+5],Fa[MN+5],cnt,found,in[MN+5],sg[MN+5],sg2[MN+5],vis[MN+5],now,f[MN+5],Vis[MN+5];
struct edge{int to,next;}e[MN+5];
inline void ins(int f,int t){e[++cnt]=(edge){t,head[f]};head[f]=cnt;}
void FindCircle(int x)
{
    if(found) return;inq[x]=1;Vis[x]=1;
    for(int i=head[x];i;i=e[i].next)
        if(inq[e[i].to])
        {
            for(int t=x;t!=e[i].to;t=Fa[t]) c[++num]=t;
            c[++num]=e[i].to;found=1;
        }
        else if(!Vis[e[i].to]) Fa[e[i].to]=x,FindCircle(e[i].to);
    inq[x]=0;
}
void Dp(int x)
{
    for(int i=head[x];i;i=e[i].next)
        if(!in[e[i].to]) Dp(e[i].to);
    ++now;for(int i=head[x];i;i=e[i].next) if(!in[e[i].to]) vis[sg[e[i].to]]=now;
    for(;vis[sg[x]]==now;++sg[x]);
    for(sg2[x]=sg[x]+1;vis[sg2[x]]==now;++sg2[x]);
}
int main()
{
    n=read();
    for(int i=1;i<=n;++i) ins(read(),i);
    for(int i=1;i<=n;++i) if(!vis[i]) FindCircle(i);
    for(int i=1;i<=num;++i) in[c[i]]=1;
    for(int i=1;i<=num;++i) Dp(c[i]);
    f[1]=sg[c[1]];
    for(int i=2;i<=num;++i) f[i]=f[i-1]==sg[c[i]]?sg2[c[i]]:sg[c[i]];
    if(f[num]!=sg[c[1]]) return 0*puts("POSSIBLE");
    f[1]=sg2[c[1]];
    for(int i=2;i<=num;++i) f[i]=f[i-1]==sg[c[i]]?sg2[c[i]]:sg[c[i]];
    if(f[num]==sg[c[1]]) return 0*puts("POSSIBLE");
    puts("IMPOSSIBLE");
    return 0;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}


void solve() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> acc(N);
    for (int i = 0; i + 1 < S.size(); i++) {
        if (S[i] == 'A' && S[i + 1] == 'C') {
            acc[i + 1] = acc[i] + 1;
        } else {
            acc[i + 1] = acc[i];
        }
    }

    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        cout << acc[r] - acc[l] << endl;
    }
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 1488
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner input = new Scanner(System.in);
    int n = input.nextInt();
    int m = input.nextInt();
    
    if(n*500>=m)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

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

int main() {
    int N;
    cin >> N;
    vector<pair<ll, ll>> p(N);
    ll pos = -1, ans = 0;
    rep(i, N) {
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(), p.end());

    rep(i, N) {
        ll X = p[i].first, L = p[i].second;
        if (pos == -1) {
            ans++;
            pos = X + L;
        }
        else {
            // 入っている
            if (pos <= X-L) {
                ans++;
                pos = X+L;
            }
            else if (X - L + 1 <= pos and pos <= X + L - 1) {
                continue;
            }
            //
            else if (pos >= X + L) {
                pos = min(pos, X + L);
                continue;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define maxn (int)(2e5)
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;
bool found[maxn+2];
int ans[maxn+2];

void getOccurances(string txt, string pat){
    int N = txt.size(), M = pat.size();
    int i,j,res;

    for(i =0; i <= N-M; i++){
        for(j = 0; j < M; j++){
            if(txt[i+j] != pat[j]) break;
        }
        if(j == M){
            res++;
            found[i+j-1] = true;
            j = 0;
        }
    }
    // for(int i=0;i<N;i++){
    //     printf("%d %d\n", i, found[i]);
    // }
    ans[0] = found[0];
    for(int i=1;i<N;i++) {
        ans[i] = ans[i-1] + found[i];
    }
}
int main() {
    /*BEFORE SUBMIT, CHECK
    sample i/o format
    statements for debugging are removed/comment out
    global values / stl containers are initialized/cleared for each test (if needed)
    all array size are sufficient
    loop variable or output value doesn't cross min/max limit of input
    
     #ifndef ONLINE_JUDGE
        fread();
    #endif
    */
    
    int n,q, l,r;
    string s; 
    while(scanf("%d %d",&n, &q)==2){
        //init();
        getchar();
        cin>>s;
        getOccurances(s, "AC");
        for(int i=0;i<q;i++){
            scanf("%d %d",&l,&r);
            l--; r--;
            // int res = ans[r];
            // if(l > 0) res-= ans[l-1];
            printf("%d\n", ans[r]- ans[l]);
        }
    }
    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int a[3][3];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> a[i][j];
    }
  }
  int n;
  cin>>n;
  vector<int> b(n);
  for(int i = 0; i < n; i++){
    cin >> b[i];
  }
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < n; k++){
        if(a[i][j] == b[k]){
          a[i][j] = -1;
        }
      }
    }
  }
  for(int i = 0; i < 3; i++){
    if((a[i][0] + a[i][1] +a[i][2])  == -3){
      cout << "Yes\n";
      return 0;
    }else if((a[0][i] + a[1][i] +a[2][i])  == -3){
      cout << "Yes\n";
      return 0;
    }
  }
  if((a[0][0] + a[1][1] + a[2][2]) == -3){
     cout << "Yes\n";
      return 0;
  }
  if((a[0][2] + a[1][1] + a[2][0]) == -3){
    cout << "Yes\n";
    return 0;
  }
  
  cout << "No\n";
  return 0;
}

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

int main(){
  string s,t;
  cin >> s >> t;
  bool ans=true;
  vector<int> a(26,-1);
  int n=s.size();
  for(int i=0;i<n;i++){
    int x=s[i]-'a';
    if(a[x]==-1) a[x]=t[i]-'a';
    else if(a[x]!=t[i]-'a') ans=false;
  }
  for(int i=0;i<26;i++){
    for(int j=i+1;j<26;j++){
      if(a[i]==a[j]&&a[i]!=-1) ans=false;
    }
  }
  cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 904
from collections import*
n,m,*t=map(int,open(0).read().split())
i,o,r=[0]*n,[[]for _ in'_'*n],[]
for a,b in zip(*[iter(t)]*2):
  o[a-1]+=b-1,
  i[b-1]+=1
q=deque(v for v in range(n)if i[v]<1)
while q:
  v=q.popleft()
  r+=v,
  for w in o[v]:
    i[w]-=1
    if i[w]==0:q+=w,
print(-(len(r)==n))


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

#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void hmax(int a){
  int l=2*a,r=2*a+1,largest, c;
  if(l<=H && A[l]>A[a])largest=l;
  else largest=a;
  if(r<=H && A[r]>A[largest])largest=r;
  if(largest != a){
    c=A[a];
    A[a]=A[largest];
    A[largest]=c;
    hmax(largest);
  }
}

int extract(){
  int maxv;
  if(H<1)return -INFTY;
  maxv=A[1];
  A[1]=A[H--];
  hmax(1);
  return maxv;
}

void iK(int i, int key){
  if(key<A[i])return;
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    swap(A[i], A[i/2]);
    i=i/2;
  }
}

void insert(int key){
  H++;
  A[H]=-INFTY;
  iK(H, key);
}

int main(){
  int key;
  char com[10];
  while(1){
    scanf("%s", com);
    if(com[0]=='e' && com[1]=='n')break;
    if(com[0]=='i'){
      scanf("%d", &key);
      insert(key);
    }else{
      printf("%d\n", extract());
    }
  }
  return 0;
}



Measured memory_bytes: 6452
import java.io.*;
import java.util.*;

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

        int n = sc.nextInt();
        double[] p = new double[n + 1];
        for (int i = 1; i <= n; i++) {
            p[i] = sc.nextDouble();
        }
        double[][] dp = new double[n + 1][n + 1];
        // dp[i][j] = with i coins probablilty of getting j heads.

        /*
         * dp[3][2] means 3 coins and getting probablity of 2 heads. hht hth thh so
         * dp[3][2] = p[3] * dp[2][1] (ht or th) + (1-p[3])*dp[2][2] (hh); --------
         * dp[i][j] = p[i]*dp[i-1][j-1] + (1-p[i])*dp[i-1][j];
         */

        dp[0][0] = 1;

        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= n; j++) {
                if (j == 0) {
                    dp[i][j] = (1.0 - p[i]) * dp[i - 1][j];
                } else {
                    dp[i][j] = p[i] * dp[i - 1][j - 1] + (1 - p[i]) * dp[i - 1][j];
                }
            }
        }
        // System.out.println(Arrays.deepToString(dp));
        double ans = 0;
        for (int i = (n + 1) / 2; i <= n; i++) {
            ans = ans + dp[n][i];
        }

        System.out.println(ans);

    }

}

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

int main(){
  int N;
  cin >> N;
  bool ans = false;
  for (int i = 1; i < 10; i++){
    for (int j = 1; j < 10; j++){
      if (i * j == N) ans = true;
    }
  }
  if(ans == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
from collections import deque
n, m = map(int, input().split())
way = [[] for i in range(n + 1)]
ans = [-1 for i in range(n + 1)]
reached = [0 for i in range(n + 1)]

for i in range(m):
    a, b = map(int, input().split())
    way[a].append(b)
    way[b].append(a)
    
D = deque([1])
while D:
    go = D.popleft()
    for i in way[go]:
        if reached[i] == 0:
            D.append(i)
            reached[i] = 1
            ans[i] = go
print("Yes")
for i in range(2, n + 1):
    print(ans[i])


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

using namespace std;

class Disjoint {
public:
    Disjoint(int n) {
        for (int i = 0; i < n; i++) {
            id.push_back(i);
            size.push_back(1);
        }
    }

    bool isConnected(int s, int t) {
        return find(s) == find(t);
    }

    int find(int vertex) {
        while (vertex != id[vertex]) {
            id[vertex] = id[id[vertex]];
            vertex = id[vertex];
        }
        return vertex;
    }

    void connect(int s, int t) {
        int sRoot = find(s);
        int tRoot = find(t);

        if (sRoot == tRoot)
            return;

        if (size[sRoot] < size[tRoot]) {
            size[tRoot] += size[sRoot];
            id[sRoot] = id[tRoot];
        }
        else {
            size[sRoot] += size[tRoot];
            id[tRoot] = id[sRoot];
        }
    }

private:
    vector<int> id;
    vector<int> size;
};

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

    Disjoint disjoint = Disjoint(n);
    int s, t;
    for (int i = 0; i < m; i++) {
        cin >> s >> t;
        disjoint.connect(s, t);
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> s >> t;
        if (disjoint.isConnected(s, t))
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }

    return 0;
}



Measured memory_bytes: 4028
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>

using namespace std;

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

ll min(ll x, ll y){
    if(x<y)return x;
    return y;
}
char s[100001];
int ans[100001];

int make(int prev, int now){
    if((ans[now] == 1 && s[now] == 'o') || (ans[now] == 0 && s[now] == 'x'))return ans[prev];
    return 1 - ans[prev];
}

int main(void){
    int n;
    scanf("%d", &n);
    scanf("%s", &s);
    ans[0] = 0;
    ans[1] = 0;
    for(int i = 2;i < n;i++){
        ans[i] = make(i-2, i-1);
    }
    if(make(n-2, n-1) == ans[0] && make(n-1, 0) == ans[1]){
        for(int i = 0;i < n;i++){
            if(ans[i])printf("S");
            else printf("W");
        }
        return 0;
    }
    ans[0] = 0;
    ans[1] = 1;
    for(int i = 2;i < n;i++){
        ans[i] = make(i-2, i-1);
    }
    if(make(n-2, n-1) == ans[0] && make(n-1, 0) == ans[1]){
        for(int i = 0;i < n;i++){
            if(ans[i])printf("S");
            else printf("W");
        }
        return 0;
    }
    ans[0] = 1;
    ans[1] = 0;
    for(int i = 2;i < n;i++){
        ans[i] = make(i-2, i-1);
    }
    if(make(n-2, n-1) == ans[0] && make(n-1, 0) == ans[1]){
        for(int i = 0;i < n;i++){
            if(ans[i])printf("S");
            else printf("W");
        }
        return 0;
    }
    ans[0] = 1;
    ans[1] = 1;
    for(int i = 2;i < n;i++){
        ans[i] = make(i-2, i-1);
    }
    if(make(n-2, n-1) == ans[0] && make(n-1, 0) == ans[1]){
        for(int i = 0;i < n;i++){
            if(ans[i])printf("S");
            else printf("W");
        }
        return 0;
    }
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 768
w, h, n = map(int, input().split())
w_2 = 0
h_2 = 0
order = []

for i in range(n):
    array = list(map(int, input().split()))
    order.append(array)

for i, j, a in order:
    if a == 1:
        w_2 = max(w_2, i)
    elif a == 2:
        w = min(w, i)
    elif a == 3:
        h_2 = max(h_2, j)
    else:
        h = min(h, j)

tate = h - h_2
yoko = w - w_2
if tate < 0 or yoko < 0:
    print(0)
    exit()
print(max(tate*yoko, 0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#define pf printf
#define sc scanf
#define sf(xx) scanf("%lld",&xx)
#define INF (1<<30)-1+(1<<30)
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;

// a new data structure defined. Please refer below
// GNU link : https://goo.gl/WVDL6g
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define fast()    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
template<class T1> void deb(T1 e1)
{
	cout << e1 << endl;
}
template<class T1, class T2> void deb(T1 e1, T2 e2)
{
	cout << e1 << " " << e2 << endl;
}
template<class T1, class T2, class T3> void deb(T1 e1, T2 e2, T3 e3)
{
	cout << e1 << " " << e2 << " " << e3 << endl;
}
#define bug(x) cerr<<#x<<" is "<<x<<endl
#define all(x) (x).begin(), (x).end()
#define unik(v) (v).erase(unique(all(v)), v.end())
#define sz(x) ((ll) (x).size())
const ll MOD = 1000000007;
int main()
{
	ll t, n, m, x, y, b, sum = 0, x1 = 0, c = 0, x2 = 0, mx = 0, u = 1, mn = 1e9;
	cin >> n >> m;
	map<ll, ll> mp;
	for (int i = 0; i < n; ++i)
		{
			cin >> x;
			while (x--)
				{
					cin >> y;
					mp[y]++;
				}
		}
	for (auto i : mp) if (i.second == n) sum++;
	deb(sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <cstdio>
#include <sstream>

#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>

#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

long long c(long long x) {
	return x * (x - 1) / 2;
}

int main(){
	long long x;
	cin >> x;
	long long s = 0;
	for(int i = 1; i <= x; i++){
		int aux = x/i;
		s += i * c(aux+1);
	}
	
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 3632
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
ma = 0
ans = []
for k, v in c.most_common():
    if v >= ma:
        ma = v
        ans.append(k)
    else:
        break
ans.sort()
print(*ans, sep='\n')


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

int main(){
 int n,m;
 string s,k;
 cin>>s>>k;
 n=s.length(),m=k.length();
 int dp[n+1][m+1];
 for(int i=0;i<=n;i++)dp[i][0]=0;
 for(int i=0;i<=m;i++)dp[0][i]=0;
 for(int i=1;i<=n;i++){
     for(int j=1;j<=m;j++){
         if(s[i-1]==k[j-1])dp[i][j]=1+dp[i-1][j-1];
         else{
          dp[i][j]=max(dp[i-1][j],dp[i][j-1]);   
         }
     }
 }
 //cout<<dp[n][m];
 int i=n,j=m;
 string f="";
 while(i>0&&j>0){
     if(s[i-1]==k[j-1]){
         f.push_back(s[i-1]);
         i--;j--;
     }
    else if(dp[i][j-1]>=dp[i-1][j]){
        j--;
    }
     else{
         i--;
     }
     //cout<<f<<endl;
 }
 reverse(f.begin(),f.end());
 cout<<f<<endl;
 return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <stdio.h>
using namespace std;
int tmp,D[100]={},ans;
void north(){
    tmp=D[0];
    D[0]=D[1];
    D[1]=D[5];
    D[5]=D[4];
    D[4]=tmp;
}
void south(){
    tmp=D[0];
    D[0]=D[4];
    D[4]=D[5];
    D[5]=D[1];
    D[1]=tmp;
}
void east(){
    tmp=D[0];
    D[0]=D[3];
    D[3]=D[5];
    D[5]=D[2];
    D[2]=tmp;
}
void west(){
    tmp=D[0];
    D[0]=D[2];
    D[2]=D[5];
    D[5]=D[3];
    D[3]=tmp;
}
void around(){
    tmp=D[1];
    D[1]=D[3];
    D[3]=D[4];
    D[4]=D[2];
    D[2]=tmp;
}
int main(){
    int a,b,d[100]={},n;
    cin>>n;
    for(int i=0;i<6;i++){
        cin>>D[i];
    }
    for(int l=0;l<n;l++){
        for(int i=0;i<6;i++){
            cin>>d[i];
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                for(int k=0;k<4;k++){
                    around();
                    if(D[0]==d[0] && D[1]==d[1] && D[2]==d[2] && D[3]==d[3] && D[4]==d[4] && D[5]==d[5]){
                        cout<<"No"<<endl;
                        return 0;
                    }
                }
                west();
            }
            north();
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

int cal(string na,string me){
  int l=na.size();
  int r=me.size();
  int h[1005][1005];
  for(int i=0;i<l;i++){
    for(int j=0;j<r;j++){
      h[i][j]=0;
    }
  }

  int ans=0;
  for(int i=1;i<=l;i++){
    for(int j=1;j<=r;j++){

      if(na[i-1]==me[j-1]) h[i][j]=h[i-1][j-1]+1;
      else h[i][j]=max(h[i][j-1],h[i-1][j]);

      ans=max(ans,h[i][j]);
    }
  }
  return ans;
}

int main(){
  int n,ans=0;
  cin>>n;

  string na,me;
  for(int i=0;i<n;i++){
    cin>>na>>me;
    ans=cal(na,me);
    cout<<ans<<endl;
  }

  return 0;
}



Measured memory_bytes: 7112
#include <stdio.h>

#define TRUE  1
#define FALSE  0

int solve(int, int);
int n, a[20];

int main(void)
{
  int q, i, m[200];
  scanf("%d", &n);
  for (i = 0; i < n; i++)  {
    scanf("%d", &a[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; i++)  {
    scanf("%d", &m[i]);
  }
  for (i = 0; i < q; i++)  {
    if (solve(0, m[i]) == TRUE)  {
      puts("yes");
    }
    else  {
      puts("no");
    }
  }
  return 0;
}

int solve(int i, int m)
{
  if (m == 0)  {
    return TRUE;
  }
  else if (i >= n)  {
    return FALSE;
  }

  return solve(i + 1, m) || solve(i + 1, m - a[i]);
}

Measured memory_bytes: 580
#include <iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.length();
    int n1=(n-1)/2;
    for(int i=0;i<n1;i++){
        if(s[i]!=s[n-i-1]){
            cout<<"No";
            return 0;
        }
    }
    int n2;
    if(0==n1%2){
        n2=n1/2;
    }else{
        n2=(n1-1)/2;
    }
    for(int i=0;i<n2;i++){
        if(s[i]!=s[n1-i-1]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890

using namespace std;

int H[100007];

int main()
{
    int i,j;
    int N;

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

    if(N==1)
    {
        printf("Yes\n");
        return 0;
    }

    H[0]--;
    bool flag= 0;
    for(i=1;i<N;i++)
    {
        if(H[i] > H[i-1])
        {
            H[i]--;
        }
        else if(H[i]<H[i-1])
        {
            flag= 1;
            break;
        }
    }

    if(flag)
        printf("No\n");
    else
        printf("Yes\n");


    return 0;
}


Measured memory_bytes: 640
<?php
$map = array_fill(0,100001,1);
$map[1] = 0;
for($i = 1; $i <= 3200; $i++){
  if($map[$i] == 1){
    for($j = 2; $i * $j < 100000; $j++){
      $map[$i*$j] = 0;
    }
  }
}
$sum[-1] = 0;
for($i = 1; $i < 100000; $i+=2){
  $sum[$i] = $sum[$i-2] + $map[$i]*$map[($i+1)/2];
}
$Q = intval(fgets(STDIN));
for($i = 0; $i < $Q; $i++){
  list($l, $r) = array_map("intval", explode(" ", trim(fgets(STDIN))));
  $result[] = $sum[$r]-$sum[$l-2];
}
echo implode("\n", $result),"\n";



Measured memory_bytes: 19064
N = int(input())
if N == 1:
    print('Yes')
else:
    ans = 'No'
    for i in range(1, min(N//2+1, 10)):
        if N % i == 0:
            n = N // i
            if n < 10:
                ans = 'Yes'
                break
    print(ans)

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    string a, b, c;
    cin >> a >> b >> c;
    YN(a.at(a.size()-1) == b.at(0) && b.at(b.size()-1) == c.at(0))
}




Measured memory_bytes: 256
#include <stdio.h>
#define N 8
#define NOTFREE -1
#define FREE 1

int r,c;
int k[N][N],row[N],col[N],dpos[15],dneg[15];

void putQueen(int i){
  int j;

  if( i == N ){
    printBoard();
    return;
  }

  for( j = 0; j < N; j++){
    if(col[j]==NOTFREE||dpos[i+j]==NOTFREE||dneg[i-j+N-1]==NOTFREE) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOTFREE;
    putQueen(i+1);
    col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
} 

void printBoard(void){
  int i,j;

  for( i = 0; i < N; i++){
    for( j = 0; j < N; j++){
      if( k[i][j] == NOTFREE && row[i] != j) return;
    }
  }

  for( i = 0; i < N; i++){
    for( j = 0; j < N; j++){
      if( row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

int main() {
  int i,j,n;

  for( i = 0; i < N; i++){
    row[i]=FREE;
    col[i]=FREE;
    for( j = 0; j < N; j++){
      k[i][j]=0;
    }
  }
  for( i = 0; i < 15; i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }

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

  putQueen(0);

  return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認
ll A[30];

int main(){
   string S,T;
   cin >> S >> T;
   ll ans = 0;
   rep(i,S.size()) if(S[i] != T[i]) ans++;
   cout << ans << endl;
}

Measured memory_bytes: 3916
n=int(input())
def isdig(n):
  if n>=0:
    digit=0
    while n>2**digit:
      n-=2**digit
      digit+=2
  else:
    digit=1
    while n<-2**digit:
      n+=2**digit
      digit+=2
  return digit
x=["0"]*(isdig(n)+1)
while n!=0:
  digit=isdig(n)
  if digit%2==0:
    n-=2**digit
  else:
    n+=2**digit
  x[digit]="1"
x.reverse()
print("".join(x))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int main() {
    int a; cin >> a;
    string s; cin >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}



Measured memory_bytes: 256
/*---------------------------------
 *File name: A.cpp
 *Creation date: 2020-07-05 19:35
 *Link: 
 *-------------------------------*/
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define LL long long
#define PII pair<int, int>
#define Pque priority_queue 
using namespace std;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const double EPS = 1e-8;

char s[10][10];
int h, w, k;
int allr[10], allc[10];

int check(int x, int y){
	vector<int> r, c;
	while(x){
		r.pb(x & 1);
		x >>= 1;
	}
	while(y){
		c.pb(y & 1);
		y >>= 1;
	}
	while(r.size() < h) r.pb(0);
	while(c.size() < w) c.pb(0);
	char t[10][10];
	for(int i = 1; i <= h; ++i) strcpy(t[i] + 1, s[i] + 1);

	for(int i = 1; i <= h; ++i){
		if(r[i - 1] == 1){
			for(int j = 1; j <= w; ++j) t[i][j] = '!';
		}
	}
	for(int i = 1; i <= w; ++i){
		if(c[i - 1] == 1){
			for(int j = 1; j <= h; ++j) t[j][i] = '!';
		}
	}	
	int cnt = 0;
	for(int i = 1; i <= h; ++i){
		for(int j = 1; j <= w; ++j){
			cnt += (t[i][j] == '#' ? 1 : 0);
		}
	}
	return cnt;
}

int main(){
	scanf("%d %d %d", &h, &w, &k);
	for(int i = 1; i <= h; ++i) scanf(" %s", s[i] + 1);
	for(int i = 1; i <= h; ++i){
		for(int j = 1; j <= w; ++j){
			if(s[i][j] == '#') allr[i]++, allc[j]++;
		}
	}
	int ans = 0;
	int rup = (1 << h);
	int cup = (1 << w);
	for(int i = 0; i < rup; ++i){
		for(int j = 0; j < cup; ++j){
			if(check(i, j) == k) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3264
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine();
            string[] spritted = read.Split(' ');
            int a = Int32.Parse(spritted[0]);
            int b = Int32.Parse(spritted[1]);
            int c = Int32.Parse(spritted[2]);

            if (2 * b == a + c)
            {
                Console.WriteLine("YES");
            }
            else
                Console.WriteLine("NO");

        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define d double
#define INF (INT_MAX/2)
#define output for(int i=0;i<sizex;i++) { for(int j=0;j<sizey;j++) { cout << moveChart[i][j] << " "; }cout<<endl; }cout<<endl;

int n;
int arr[100000];
int dp[100000];

int solve( int x ){

    if( x == 0 ) return 0; 
    if( x < 0 ) return INF;

    if( dp[x] != -1 ) return dp[x];

    return dp[x] = min( solve( x-1 ) + abs( arr[x] - arr[x-1] ), solve( x-2 ) + abs( arr[x] - arr[x-2] ) );

}

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

    cin >> n;
    for(int i=0;i<n;i++) cin >> arr[i];

    memset( dp, -1, sizeof dp );
    cout << solve( n-1 ) << endl;

}

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

int main() {
    int R;
    cin >> R;
    if (R < 1200) {
        cout << "ABC" << endl;
    } else if (R < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  string s; cin >>s;
  bool r = (s[2]==s[3] && s[4]==s[5]);
  cout <<  (r?Liny:Linn);
}

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

int main() {
  int a,b;
  cin >> a >> b;
  vector <int> h(1000,0);
    for (int i=1 ; i<1000;i++){
      h.at(i) = h.at(i-1)+i ;
    }
  cout << h.at(b-a)-b << endl;
}

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

int main(){
	int W , H , x , y, r ;
	cin >> W >> H >> x >> y >> r;

	if( 0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H)
	{
		cout << "Yes" << endl;
	}
         else{cout << "No" << endl;}

	return 0;
}

Measured memory_bytes: 3080
#include <iostream>
using namespace std;
int main() {
  int N; cin >> N;
  int p[N], base = 0, index = 0;
  for(int i = 0; i < N; i++) {
    cin >> p[i];
    if(p[i] > base) {
      base = p[i];
      index = i;
    }
  }
  int sum = 0;
  for(int i = 0; i < N; i++) {
    if(i == index) {
      sum += p[i] / 2;
    } else {
      sum += p[i];
    }
  }
  cout << sum << endl;
}


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

const int mod = 1e9+7;
const int INF = 2000000;


int main() {
    int R;
    cin >> R;
    double pi = acos(-1);
    double ans = 2*R*pi;
    cout << ans << endl;
}


Measured memory_bytes: 3788
// $ gcc -o C_Candies C_Candies.c

#include <stdio.h>

int main(void) {
  int N;
  scanf("%d", &N);
  int A[2][N];
  for (int i=0; i<2; i++) {
    for (int j=0; j<N; j++) {
      scanf("%d", &(A[i][j]));
    }
  }

  int max = 0;
  for (int n=0; n<N; n++) {
    int sum = 0;
    for (int n1=0; n1<=n; n1++) {
      sum += A[0][n1];
      // printf("A[0][%d]: %d\n", n1, A[0][n1]);
    }
    for (int n2=n; n2<N; n2++) {
      sum += A[1][n2];
      // printf("A[1][%d]: %d\n", n2, A[1][n2]);
    }
    // printf("sum: %d\n", sum);
    if (sum > max) max = sum;
  }
  printf("%d\n", max);
}


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

int main(){
  ll n,x[100]={0},v;
  cin >> n;
  char s;
  FOR(i,n){
    cin >> s;
    v=(s - 'a');
    x[v]++;
  }
  ll ans=1;
  FOR(j,26){
    ans*=((x[j]+1)%MOD);
    ans%=MOD;
  }
  ans--;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define INF -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 100000
int n,Q[100],num[100][100];
int color[100],d[100],f[100],tail=0,head=0;

void enqueue(int x){
  Q[tail]=x;
  if(tail+1==MAX) tail=0;
  else tail++;
}

int dequeue(){
  int x;
  x=Q[head];
  if((head+1)==MAX)  head=0;
  else head++;
  return x;
}


int main(){
  int i,j,u,k,v;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) num[i][j]=0;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      num[u][v]=1;
    }
  }
  bfs(0);
  return 0;
}

void bfs(int y){
  int i,u,v;
  for(u=0;u<n;u++){
    color[i] = WHITE;
    d[u] = INF;
  }
  color[y] = GRAY;
  d[y]=0;
  enqueue(y);

  while (head != tail){
    u=dequeue();
    for(v=0;v<n;v++){
      if(num[u][v]==1){
        if( color[v]==WHITE){
          color[v]=GRAY;
          d[v]=d[u]+1;
          enqueue(v);
        }
      }
    }
    color[u]=BLACK;
  }
  for(i=0;i<n;i++){
    printf("%d %d\n",i+1,d[i]);
  }
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;

  if( c == 'a' ||
     c == 'i' ||
     c == 'u' ||
     c == 'e' ||
     c == 'o' ){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(ll &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
ll a[4],n,res=6e18;
ll solve(ll n, int S){
	ll res=0;
	if(S>>3&1)res+=n/8*a[3],n%=8;
	if(S>>2&1)res+=n/4*a[2],n%=4;
	if(S>>1&1)res+=n/2*a[1],n%=2;
	if(S>>0&1)res+=n/1*a[0],n%=1;
	return !n?res:6e18;
}
int main() {
	rep(i,0,3)read(a[i]);rep(i,1,3)a[i]=min(a[i],a[i-1]*2);
	read(n);//cout<<n/2*a[3]+n%2*a[2];return 0;
	n*=4;cout<<n/8*a[3]+(n%8/4)*a[2];return 0;
//	rep(i,1,15)res=min(res,solve(n,i));
	cout<<solve(n,15);
	return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    sort(A.begin(), A.end(), greater<int>());
    int64 ans = 0;
    for(int i = 0; i < N; ++i) {
        if(i >= K) ans += A[i];
    }
    cout << ans << '\n';
    return 0;
}

// overflow
// corner cases


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

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

int main(){

	int N, A, B;
	cin >> N >> A >> B;
	cout << min(A * N, B) << endl;

	return 0;
}

Measured memory_bytes: 256