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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, k; cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  double sum = 0;
  rep(i, k) sum += (double)(p[i]+1)/2;

  double ans = sum;

  rep(i, n-k) {
    sum -= (double)(p[i]+1)/2;
    sum += (double)(p[i+k]+1)/2;

    chmax(ans, sum);
  }
  printf("%0.12f\n",ans);
}


Measured memory_bytes: 3972
line = input().split(" ")
n = int(line[0])
a = int(line[1])
b = int(line[2])
nsum = 0

for i in range(1, n+1, 1):
    sum = 0
    ii = i
    for j in range(len(str(ii))-1, -1, -1):
        sum += (ii // 10**j)
        if(j != 0):
            ii -= (ii // 10**j) * 10**j
    if((sum >= a) and (sum <= b)):
        nsum += i

print(nsum)


Measured memory_bytes: 3064
#include<stdio.h>

int ans;

void swap_(int *f, int *b) {
int temp;
temp = *f;
*f = *b;
*b = temp;
ans++;
}

void bSort(int arr[], int n) {

    for(int i = 0; i < n-1; i++) {
        for(int j = 0; j < n-i-1; j++) {
		if ( arr[j] > arr[j+1])
	     swap_(&arr[j], &arr[j+1]);
        }
    }
    return;
}


int main() {

    int n;
    int arr[100+5];
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &arr[i]);
    bSort(arr, n);
    for(int i = 0; i < n ; i++) {
        if( i > 0 ) printf(" ");
        printf("%d", arr[i]);
    }
    printf("\n%d\n", ans);
    return 0;
}



Measured memory_bytes: 2692
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

struct ParseInfo {
  int pos;
  bool val;
};

set<char> char_set;
bool char_table[256];

ParseInfo parse_formula(int pos, const string& str){

  if('a' <= str[pos] && str[pos] <= 'k'){
    bool val = char_table[str[pos]];
    ParseInfo pi = {pos+1,val};
    return pi;
  }

  else if(str[pos] == 'T'){
    bool val = true;
    ParseInfo pi = {pos+1,val};
    return pi;
  }

  else if(str[pos] == 'F'){
    bool val = false;
    ParseInfo pi = {pos+1,val};
    return pi;
  }

  else if(str[pos] == '-'){
    ParseInfo pi = parse_formula(pos+1,str);
    pi.val = !pi.val;
    return pi;
  }

  else if(str[pos] == '('){
    ParseInfo pi1 = parse_formula(pos+1,str);
    if(str[pi1.pos] == '*'){
      ParseInfo pi2 = parse_formula(pi1.pos+1,str);
      pi2.val = (pi1.val && pi2.val);
      
      //skip ')'
      pi2.pos++;
      return pi2;
    }
    else if(str[pi1.pos] == '+'){
      ParseInfo pi2 = parse_formula(pi1.pos+1,str);
      pi2.val = (pi1.val || pi2.val);

      //skip ')'
      pi2.pos++;
      return pi2;
    }
    else if(str[pi1.pos] == '-'
	    && str[pi1.pos+1] == '>'){
      ParseInfo pi2 = parse_formula(pi1.pos+2,str);
      pi2.val = (!pi1.val || pi2.val);

      //skip ')'
      pi2.pos++;
      return pi2;
    }
  }
}

ParseInfo parse_equation(int pos, const string& str){
  ParseInfo pi1 = parse_formula(pos,str);
  
  //skip '='
  ParseInfo pi2 = parse_formula(pi1.pos+1,str);
  pi2.val = (pi1.val == pi2.val ? true : false);
  return pi2;
}


int main(){
  string str;
  while(cin >> str){
    if(str == "#") break;

    char_set.clear();
    for(int i=0;i<str.size();i++){
      if('a' <= str[i] && str[i] <= 'k'){
	char_set.insert(str[i]);
      }
    }

    bool isok = true;
    for(int S=0;S<=(1<<char_set.size())-1;S++){
      int idx = 0;
      for(set<char>::iterator it = char_set.begin();
	  it != char_set.end();
	  it++){
	char_table[*it] = (S & (1<<idx));
	idx++;
      }
      ParseInfo pi = parse_equation(0,str);
      if(!pi.val) isok = false;
    }
    printf("%s\n",isok ? "YES" : "NO");
  }
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string N;
    cin >> N;
    string rn;
    rn = N;
    reverse(all(rn));
    if (rn== N)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    ans = 0
    if n >= 10000:
        max_n = 99999 if n >= 100000 else n
        ans += max_n - 9999
    if n >= 100:
        max_n = 999 if n >= 1000 else n
        ans += max_n - 99
    if n >= 1:
        max_n = 9 if n >= 10 else n
        ans += max_n
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product
import math

N = int(input())
s = input().split()
p = [int(w) for w in s] #これで勝手にNまで拾ってくれます
ans_list = [0 for i in range(N)]

for i in range(len(p)):
    ans_list[p[i]-1] += 1

for i in range(N):
    print(ans_list[i])

Measured memory_bytes: 36120
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;

#[fastout]
fn main() {
    input! {
        _: usize,
        ss: Chars,
    }
    let mut matches = vec![false; 1000];
    for i in 0..1000 {
        let num: Vec<char> = format!("{:>03}", i).chars().collect();
        let mut index = 0;
        for &s in &ss {
            if s == num[index] {
                index += 1;
            }
            if index == 3 {
                matches[i] = true;
                break;
            }
        }
    }
    let ans = matches.iter().filter(|&&x| x).count();
    println!("{}", ans);
}


Measured memory_bytes: 2356
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N,M = I()
S = list(s())
T = list(s())
n = lcm(N,M)
l = (N-1)//(n//M)
for i in range(l+1):
    if S[i*(n//M)] != T[i*(n//N)]:
        print(-1)
        exit()
print(n)

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

using namespace std;

const int max_n = 100111, inf = 1000111222;

int n, k, s;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d%d", &n, &k, &s);
    int x = s + 1;
    if (s == 1000000000) {
        x = 1;
    }
    for (int i = 0; i < k; ++i) {
        printf("%d ", s);
    }
    for (int i = k; i < n; ++i) {
        printf("%d ", x);
    }
    return 0;
}


Measured memory_bytes: 1280
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


class UF_tree:
    def __init__(self, n):
        self.root = [-1] * (n + 1)  # -1ならそのノードが根,で絶対値が木の要素数
        self.rank = [0] * (n + 1)

    def find(self, x):  # xの根となる要素番号を返す
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

    def isSame(self, x, y):
        return int(self.find(x) == self.find(y))

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def getNodeLen(self, x):
        return -self.root[self.find(x)]


if __name__ == "__main__":
    N, Q = map(int, input().split())
    uf = UF_tree(N)
    ans = []
    for _ in range(Q):
        com, x, y = map(int, input().split())
        if com:
            ans.append(uf.isSame(x, y))
        else:
            uf.unite(x, y)
    print(*ans, sep="\n")


Measured memory_bytes: 7276
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> s(n + 1, 0);
    s[0] = 0;
    for (int i = 1; i < n + 1; i++)
    {
        cin >> s[i];
        s[i] += s[i - 1];
    }
    int minv = 1 << 20;
    for (int i = 1; i < n + 1; i++)
    {
        int temp = s[n] - s[i];
        minv = min(minv, max(temp-s[i],s[i]-temp));
    }
    cout << minv << endl;
    return 0;
}

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

const int INF = 2e9;

int main(){
    int n,m;
    cin >> n >> m;
    Graph g(n + 1);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> dist(n+1,-1);
    queue<int> que;
  	que.push(1);
    dist[1] = 0;
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(int nv : g[v]){
            if(dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
    if(dist[n] == 2) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 13168
n = int(input())
h = list(map(int,input().split()))
count = 0
ans = []
for i in range(n):
  if i == n-1:
    ans.append(count)
    break
  if h[i] >= h[i+1]:
    count += 1
  else:
    ans.append(count)
    count = 0
print(max(ans))

Measured memory_bytes: 14224
while 1:
  n,m,p=map(int,input().split())
  if (n,m,p)==(0,0,0): break
  es=[]
  for i in range(m):
    u,v,w=map(int,input().split())
    es.extend([(u,v,w),(v,u,w)])
  
  d=[[float("inf")]*n for _ in range(n)]
  for i in range(n): d[i][i]=0
  for e in es: d[e[0]][e[1]]=e[2]
  for k in range(n):
    d=[[min(d[i][j],d[i][k]+d[k][j]) for j in range(n)] for i in range(n)]
  
  dp=[[0]*n for _ in range(n)]
  for e in es:
    if d[0][e[0]]+e[2]+d[e[1]][-1]==d[0][-1]:
      dp[e[0]][e[1]]=1
  for k in range(n):
    dp=[[dp[i][j]+dp[i][k]*dp[k][j] for j in range(n)] for i in range(n)]
  
  for _ in range(p):
    c=int(input())
    print(dp[0][c]*dp[c][-1]/dp[0][-1])

Measured memory_bytes: 8088
/*
                                             ::                     ::
                                             ':                     :
                                              :.                    :
                                           ;' ::                   ::  '
                                          .'  ';                   ;'  '.
                                         ::    :;                 ;:    ::
                                         ;      :;.             ,;:     ::
                                         :;      :;:           ,;"      ::
                                         ::.      ':;  ..,.;  ;:'     ,.;:
                                          "'"...   '::,::::: ;:   .;.;""'
                                              '"""....;:::::;,;.;"""
                                          .:::.....'"':::::::'",...;::::;.
                                         ;:' '""'"";.,;:::::;.'""""""  ':;
                                        ::'         ;::;:::;::..         :;
                                       ::         ,;:::::::::::;:..       ::
                                       ;'     ,;;:;::::::::::::::;";..    ':.
                                      ::     ;:"  ::::::"""'::::::  ":     ::
                                       :.    ::   ::::::;  :::::::   :     ;
                                        ;    ::   :::::::  :::::::   :    ;
                                         '   ::   ::::::....:::::'  ,:   '
                                          '  ::    :::::::::::::"   ::
                                             ::     ':::::::::"'    ::
                                             ':       """""""'      ::
                                              ::                   ;:
                                              ':;                 ;:"


                                                     P_r_A_d_Y
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 300005;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void cs(int &x)
{
    cout << "Case #" << x << ": ";
}
bool cmp(string a, string b)
{
    return a + b < b + a;
}

int32_t main()
{
    fastIO;
    // int t; cin >> t;
    // int x = 1;
    // while (t--)
    // {

        string s;cin>>s;
        if(s=="ARC")
        cout<<"ABC"<<endl;
        else
            cout<<"ARC"<<endl;

    //}
    return 0;
}

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

int main()
{
	int a[1000000];
	int checker = 0, s , i = 0;

	cin >> s;

	while (checker == 0) {
		a[i] = s;

		for (int j = 0; j < i; j++) {
			if (a[j] == s) checker = 1;
		}

		if (s % 2 == 0) {
			s = s / 2;
		}
		else {
			s = 3 * s + 1;
		}

		i++;
	}

	cout << i;

	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define REVERSE(c) reverse((c).begin(), (c).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort((c).begin(),(c).end())
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
	LL N, K;
	cin >> N >> K;
	vector<PII> S(N);
	REP(i, N) {
		LL t, d;
		cin >> t >> d;
		S[i] = MP(d, t);
	}

	RSORT(S);   // by d

	// choose according only to d
	// remove max d sushi for each type
	priority_queue<PII, vector<PII>, greater<PII>> H;   // search min with O(logK)
	set<LL> used_type;
	LL d_sum = 0;
	REP(i, K) {
		d_sum += S[i].first;
		if (EXIST(used_type, S[i].second)) {
			H.push(S[i]);
		} else {
			used_type.insert(S[i].second);
		}
	}
	LL max_p = d_sum + SZ(used_type) * SZ(used_type);

	// increase # of type as many as possible
	LL s_index = K;   // index of the candidate of the next suchi
	while (s_index < N && SZ(H) > 0) {
		// pop min d from H
		LL min_d = H.top().first;
		H.pop();
		d_sum -= min_d;

		// add max d from a new type
		while (s_index < N) {
			if (!EXIST(used_type, S[s_index].second)) {
				used_type.insert(S[s_index].second);
				break;
			} else {
				s_index++;
			}
		}
		if (s_index == N) {
			break;   // no more sushi
		} else {
			d_sum += S[s_index].first;
		}
		
		LL p = d_sum + SZ(used_type) * SZ(used_type);
		if (p > max_p) {
			max_p = p;
		}
	}

	cout << max_p << endl;

    return 0;
}


Measured memory_bytes: 5752
class SegmentTree:
    def __init__(self, N_, element, function_=(lambda l, r: l + r)):
        """
        :param N_: セグ木のサイズ
        :param element: 単位元
        :param function: 子の要素に対して行われる計算,デフォルトだと加算
        """
        self.N = 1
        while self.N < N_:
            self.N *= 2

        self.element = element
        self.dat = [element for _ in range(self.N * 2)]
        self.function = function_

    def update(self, k, a):
        """k番目の値(0-indexed)をaに変更"""
        k += self.N - 1
        self.dat[k] = a

        while k > 0:
            k = (k - 1) // 2
            self.dat[k] = self.function(self.dat[2 * k + 1], self.dat[2 * k + 2])

    def query(self, begin, end, k=None, l=None, r=None):
        if k is None: return self.query(begin, end, 0, 0, self.N)

        if r <= begin or end <= l: return self.element
        if begin <= l and r <= end: return self.dat[k]

        vl = self.query(begin, end, k * 2 + 1, l, (l + r) // 2)
        vr = self.query(begin, end, k * 2 + 2, (l + r) // 2, r)
        return self.function(vl, vr)


n, q = map(int, input().split())
n += 1
treeone = SegmentTree(n, 0, (lambda l, r: l + r))

while q > 0:
    q -= 1
    tmp = list(map(int, input().split()))
    if tmp[0] is 0:
        treeone.update(tmp[1],treeone.query(tmp[1], tmp[1] + 1) + tmp[2])
    else:
        print(treeone.query(tmp[1], tmp[2] + 1))



Measured memory_bytes: 10868
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  
  vector<ll> p(a), q(b), r(c);
  for (int i = 0; i < a; i++){
    cin >> p[i];
  }
  for (int i = 0; i < b; i++){
    cin >> q[i];
  }
  for (int i = 0; i < c; i++){
    cin >> r[i];
  }
  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  sort(r.begin(), r.end());
  
  
  ll sum = 0;
  int ida = a - 1, idb = b - 1, idc = c - 1;
  while (a - 1 - ida + b - 1 - idb + c - 1 - idc < x + y){
    if (a - 1 - ida == x){
      if (q[idb] <= r[idc]){
        sum += r[idc];
        idc--;
      }
      else {
        sum += q[idb];
        idb--;
      }
    } 
    else if (b - 1 - idb == y){
      if (p[ida] <= r[idc]){
        sum += r[idc];
        idc--;
      }
      else {
        sum += p[ida];
        ida--;
      }
    }
    else {
      if (p[ida] < r[idc] && q[idb] < r[idc]){
        sum += r[idc];
        idc--;
      }
      else if (p[ida] >= r[idc] && p[ida] >= q[idb]){
        sum += p[ida];
        ida--;
      }
      else {
        sum += q[idb];
        idb--;
      }
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 2560
n=int(input())
l=[list(map(int, input().split())) for i in range(n)]
ans=0
for i in range(n-1,0,-1):
    if l[i][0]%l[i][1]!=0:
        ans+=l[i][1]-l[i][0]%l[i][1]
    l[i-1][0]+=ans

print(ans+l[0][1]-l[0][0]%l[0][1] if l[0][0]%l[0][1]!=0 else ans)

Measured memory_bytes: 60504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }



void solve() {
    int n, m; // スイッチ, 電球
    cin >> n >> m;
    vector<vector<int> > v(m, vector<int>(n));
    rep(i, m) {
        int k;
        cin >> k;
        rep(j, k) {
            int s;
            cin >> s;
            s--;
            v[i][s] = 1;
        }
    }
    vector<int> p(m);
    rep(i, m) cin >> p[i];
    
    int ans = 0;
    rep(i, 1 << n) {
        vector<int> sum(m);
        rep(j, n) {
            if (i & (1 << j)) {
                rep(k, m) {
                    if (v[k][j]) sum[k]++;
                }
            }
        }
        int cnt = 0;
        rep(j, m) if (sum[j] % 2 == p[j]) cnt++;
        if (cnt == m) ans++;
    }
    cout << ans << endl;
}


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




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

int main() {
  int n, k, x;
  x = 1;

  std::cin >> n >> k;
  
  for (int i = 0; i < n; i++) {
    if (x * 2 >= x + k) {
      x = x + k;
    } else {
      x = x * 2;
    }
  }
  
  std::cout << x << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a, b;
	
	scanf("%d %d" ,&a,&b);
	
	if (a < b)
	{
		printf("a < b\n");
	}
	else if (a>b)
	{
		printf("a > b\n");
	}
	else
	{
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2584
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
t,a = Is()
lis = Is()
tmin = 10**10
for i in range(n):
    if abs(a-(t-lis[i]*0.006)) < tmin:
        tmin = abs(a-(t-lis[i]*0.006))
        tmin_i = i
print(tmin_i+1)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,N;
  cin >> K >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++)
    cin >> A.at(i);
  
  int x;
  x=A.at(0)+K-A.at(N-1);
  
  reverse(A.begin(),A.end());
  
  for(int i=0;i<N-1;i++)
    A.at(i)-=A.at(i+1);
  
  A.at(N-1)=x;
  
  sort(A.begin(),A.end());
  
  cout << K-A.at(N-1) << endl;
}

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

int main(){
  long n;
  map<long,long> mp;
  cin >> n;
  vector<long> a(n),b(n),c;
  for(int i = 0;i < n;i++){
    cin >> a.at(i) >> b.at(i);
    if(mp[b.at(i)] == 0){
      c.push_back(b.at(i));
    }
    mp[b.at(i)] += a.at(i);
  }
  sort(c.begin(),c.end());
  long time = 0;
  bool possible = true;
  for(int i = 0;i < c.size();i++){
    time += mp[c.at(i)];
    if(time > c.at(i)){
      possible = false;
    }
  }
  if(possible == true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main() {
    int n; cin >> n;
    ll power = 1;

    for (int i = 1; i <= n; ++i) {
        power *= i;
        power %= mod;
    }
    print(power);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         
#include <complex>

using namespace std;
#define ll long long

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(a - x) < abs(b - x))
    cout << 'A' << endl;
  else
    cout << 'B' << endl;
  return 0;
}

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

typedef long long ll;

const int MAXN = 5000005;

int X, Y, Z, a, b, c, n;
ll S[MAXN];
ll num[MAXN];
ll ans[MAXN];

inline ll get_S(int x) {
    return x < 0 ? 0 : S[x];
}

ll solve(int A, int B, int C, int K) {
    if (A < 0 || B < 0 || C < 0 || K < 0)
        return 0;
    return get_S(K) - get_S(K - A - 1) - get_S(K - B - 1) - get_S(K - C - 1) + get_S(K - A - B - 2) + get_S(K - A - C - 2) + get_S(K - B - C - 2) - get_S(K - A - B -C - 3);
}

int main() {
    S[0] = 1;
    for (int i = 1; i <= 5000000; i++)
        S[i] = S[i - 1] + i + 1;
    for (int i = 1; i <= 5000000; i++)
        S[i] += S[i - 1];

    scanf("%d %d %d %d %d %d", &X, &Y, &Z, &a, &b, &c);
    scanf("%d", &n);

    num[0] = 1; int p;
    for (int k = 1; ; k++) {
        ll &sum = num[k];
        sum += solve(X - 1 - a, Y - 1 - b, Z - 1 - c, k);
        sum += solve(X - 1 - a, Y - 1 - b, c - 1, k - 1);
        sum += solve(X - 1 - a, b - 1, Z - 1 - c, k - 1);
        sum += solve(a - 1, Y - 1 - b, Z - 1 - c, k - 1);
        sum += solve(X - 1 - a, b - 1, c - 1, k - 2);
        sum += solve(a - 1, Y - 1 - b, c - 1, k - 2);
        sum += solve(a - 1, b - 1, Z - 1 - c, k - 2);
        sum += solve(a - 1, b - 1, c - 1, k - 3);

        if (sum <= num[k - 1]) {
            p = k - 1;
            break;
        }
    }
    ans[0]++;
    for (int i = 1; i <= p; i++)
        ans[i % n] += num[i] - num[i - 1];
    for (int i = 0; i < n; i++)
        printf("%lld%c", ans[i], " \n"[i == n - 1]);
    return 0;
}



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

/*                     
*/

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define forp(i, a, b) for (int i = a; i <= b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define ren(i, n) for (int i = n - 1; i >= 0; i--)
#define forn(i, a, b) for (int i = a; i >= b; i--)
#define on cout << endl
#define o2(a, b) cout << a << " " << b
#define os cout << " "
#define all(v) v.begin(), v.end()
#define mem(n, m) memset(n, m, sizeof(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sii set<int>
#define us unordered_set<int>
#define um unordered_map<int, int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ret return 0
#define present(s, x) (s.find(x) != s.end())
#define cpresent(s, x) (find(all(s), x) != s.end())
#define ford(container, it) for (__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fors(container, it, a, b) for (__typeof(container.begin()) it = a; it != b; it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZ 1000001
#define SIZE 200001

typedef long long ll;
typedef long double ldo;
typedef double db;
using namespace std;
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

//Everything is temporary...So,enjoy little things...
void c_p_c()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int main()
{
    c_p_c();
    ll n;
    cin >> n;
    ll a;
    ll sum = 0, ans = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> a;
        if (i)
        {
            ans = (ans + ((sum * a) % MOD)) % MOD;
        }
        sum = (sum + a) % MOD;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (b == 1)
    cout << 0 << endl;
  else
    cout << (b - 2) / (a - 1) + 1 << endl;
  
  return 0;
}


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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vi a(n), b(n), c(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	ll res = 0;
	for (int i = 0; i < n; i++) {
		ll aCnt = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
		ll cCnt = b.size() - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
		res += aCnt * cCnt;
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1408
N,K = list(map(int,input().split()))

R,S,P = list(map(int,input().split()))

T = input()
ans = 0
for i in range(K):
    j = i
    count = 0
    DP = [[0]*3 for i in range((N-i-1)//K + 2)]
    
    while j<N:
        if T[j]=="r":
            DP[count+1][0] = max(DP[count][1],DP[count][2])
            DP[count+1][1] = max(DP[count][0],DP[count][2])
            DP[count+1][2] = max(DP[count][0],DP[count][1])+P
        elif T[j]=="s":
            DP[count+1][0] = max(DP[count][1],DP[count][2])+R
            DP[count+1][1] = max(DP[count][0],DP[count][2])
            DP[count+1][2] = max(DP[count][0],DP[count][1])
        elif T[j]=="p":
            DP[count+1][0] = max(DP[count][1],DP[count][2])
            DP[count+1][1] = max(DP[count][0],DP[count][2])+S
            DP[count+1][2] = max(DP[count][0],DP[count][1])
        j+=K
        count+=1
    ans += max(DP[count][0],DP[count][1],DP[count][2])

print(ans)

Measured memory_bytes: 70256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

class UnionFindTree
{
   private:
      int N;
      int *rootnum;
      int *rank;
      int *unionnum;

   public:
      UnionFindTree(int n){
         /*0からn-1までの要素をunionとしてもつ*/
         N = n;
         rootnum = new int[N];
         rank = new int[N];
         unionnum = new int[N];
         for( int i = 0 ; i < N ; i++ ){
            rootnum[i] = i;
            rank[i] = 0;
            unionnum[i] = 1;
         }
      }
      
      int Find( int j ){
         if( rootnum[j] == j ){
            return j;
         }
         else{
            return rootnum[j] = Find(rootnum[j]);
         }
      }

      void Union( int i , int j ){
         int x = Find(i);
         int y = Find(j);
         if( x == y ) return;
         N--;
         if( rank[x] < rank[y] ){
            rootnum[y] = x;
            unionnum[x] += unionnum[y];
         }else{
            rootnum[x] = y;
            unionnum[y] += unionnum[x];
            if( rank[x]==rank[y] ) rank[x]++;
         }
      }

      int Num( int j ){
         /*与えられた要素の入っている集合の要素数を答える*/
         int x = Find(j);
         return unionnum[x];
      }

      int UnionNum(){
         /*集合の数を答える*/
         return N;
      }

      ~UnionFindTree(){
         delete rootnum;
         delete rank;
         delete unionnum;
      }
};

int main(){
   int N,M;
   cin >> N >> M;
   UnionFindTree uftree(N);

   for(int i=0; i<M; i++){
      int X,Y,Z;
      cin >> X>>Y>>Z;
      X--;
      Y--;
      uftree.Union(X,Y);
   }
   cout << uftree.UnionNum()<<endl;
}


Measured memory_bytes: 1536
// https://atcoder.jp/contests/dp/tasks/dp_i
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

// dp[i][j]dp[i][j]  := 最初の ii 枚のコインを投げたときに、表が jj 枚となる確率
double dp[3100][3100];

int main()
{
    int N;
    cin >> N;
    vector<double> p(N);
    rep(i, 0, N) cin >> p[i];

    dp[0][0] = 1.0;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
        }
    }

    double res = 0.0;
    for (int j = (N + 1) / 2; j <= N; j++) res += dp[N][j];
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}

Measured memory_bytes: 72320
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        char[] num = new char[n.length()];
        int sum = 0;
        for(int i = 0; i < n.length(); i++){
            num[i] = n.charAt(i);
            sum += Integer.parseInt(String.valueOf(n.charAt(i)));
        }
        System.out.println(sum%9==0?"Yes":"No");
    }
}

Measured memory_bytes: 50180
#include "bits/stdc++.h"
using namespace std;
int n, v[110];
long long W, w[110], dp[110][100010];
int main()
{
	cin >> n >> W;
	for(int i = 1; i <= n; i++) cin >> w[i] >> v[i];
	for(int i = 0; i <= n; i++) for(int j = 1; j < 100010; j++) dp[i][j] = 1e18;
	for(int i = 1; i <= n; i++) for(int j = 1; j < 100010; j++)
	{
		dp[i][j] = dp[i - 1][j];
		if(j >= v[i]) dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
	} 
	for(int i = 100009; i >= 0; i--) if(dp[n][i] <= W)
	{
		cout << i << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 80128
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt

from sys import exit

from copy import deepcopy
import numpy as np

import bisect
import re
import heapq


ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



def main():
    n = ii()
    t = []
    for i in range(n):
        t.append(ii())

    g = t[0]
    for i in range(1,n):
        g = g*t[i]//gcd(g,t[i])
    
    print(g)

main()


Measured memory_bytes: 15300
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {

			int a = sc.nextInt();
			int p = sc.nextInt();

			int result = (3 * a + p) / 2;
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 23764
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Checker c;
		String line;
		
		while(true){
			line = sc.nextLine();
			if(line.equals(".")){
				break;
			}else if(!line.isEmpty()){
				c = new Checker(line);
				if(c.scanLine()){
					System.out.println("yes");
				}else{
					System.out.println("no");
				}
			}
		}
		
	}
}

class Checker {
	String line;
	Stack<String> stack;
	
	public Checker(String line){
		this.line = line;
		stack = new Stack<String>();
	}
	
	public boolean scanLine(){
		if(!(line.charAt(line.length()-1) == '.')){
			return false;
		}
		
		for(int i=0; i<line.length(); i++){
			if(line.charAt(i) == '('){
				stack.push("(");
			}else if(line.charAt(i) == ')'){
				if(stack.size() == 0){
					return false;
				}else if(stack.pop() != "("){
					return false;
				}
			}else if(line.charAt(i) == '['){
				stack.push("[");
			}else if(line.charAt(i) == ']'){
				if(stack.size() == 0){
					return false;
				}else if(stack.pop() != "["){
					return false;
				}
			}
		}
		
		if(stack.size() != 0){
			return false;
		}
		
		return true;
	}
}

Measured memory_bytes: 32220
n,m = map(int,input().split())

rest = []
for i in range(m):
    a,b = input().split()
    rest.append((int(a),b))

done = False

for i in range(0,1000):
    x = str(i)
    if (len(x) == n):
        ok = True
        for t in rest:
            if (x[t[0] - 1] != t[1]):
                ok = False
                break
        if ok:
            print(i)
            done = True
            break

if not done:
    print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323;
typedef long long ll;
int main(){
    int a[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin>>n;
    cout<<a[n];
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
long long int dp[102][100001],arr[102][2],n,w;
long long int calc(long long int i,long long int c)
{
	if(dp[i][c]!=-1)
		return dp[i][c];
	else if(i==1)
	{
		if(c>=arr[i][0])
			dp[i][c]=arr[i][1];
		else 
			dp[i][c]=0;
		return dp[i][c];
	}
	else
	{
		long long int a=0,b;
		if(c>=arr[i][0])
			a=arr[i][1]+calc(i-1,c-arr[i][0]);
		b=calc(i-1,c);
		dp[i][c]=a>b?a:b;
		return dp[i][c];
	}
}
int main()
{
	long long int i,j,ans;
	cin>>n>>w;
	for(i=1;i<=n;i++)
		cin>>arr[i][0]>>arr[i][1];
	for(i=0;i<102;i++)
	{
		for(j=0;j<100001;j++)
		dp[i][j]=-1;
	}
	ans=calc(n,w);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 80000
L=list(map(int,input().split()))
L.sort(reverse=True)
#print(L)
ans=0
SA=L[0]-L[1]
ans+=SA
L[2]+=SA
L[1]+=SA
#print(L)
if (L[0]-L[2])%2==0:
    ans+=(L[0]-L[2])//2
    print(ans)
else:
    ans+=(L[0]-L[2])//2+1
    ans+=1
    print(ans)

Measured memory_bytes: 38384
ans = []
while True:
    m,f,r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        ans.append("F")
    elif m+f >= 80:
        ans.append("A")
    elif m+f >= 65:
        ans.append("B")
    elif m+f >= 50:
        ans.append("C")
    elif m+f >= 30 and r >= 50:
        ans.append("C")
    elif m+f >= 30:
        ans.append("D")
    else:
        ans.append("F")
        
for i in ans:
    print(i)


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

using namespace std;

int main() {
  int K;
  cin >> K;
  queue<long long> que;
  for (int i = 1; i <= 9; i++) {
    que.push(i);
  }
  long long x;
  int cnt = 0;
  while (cnt < K) {
    x = que.front();
    que.pop();
    int m = x % 10;
    if (m != 0) que.push(x * 10 + m - 1);
    que.push(x * 10 + m);
    if (m != 9) que.push(x * 10 + m + 1);
    cnt++;
  }
  cout << x << endl;

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


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n;
int calc(int* aaa,int l){
  int cnt = 0;
  int r = l+1;
  int ans = n;
  while(true){
    cnt = 0;
    int color = aaa[l];
    while(0<= l&&aaa[l] == color){
      cnt++;
      l--;
    }
    while(n > r&& aaa[r] == color){
      cnt++;
      r++;
    }
    if(cnt < 4)break;
    else ans -= cnt;
  }
  return ans;
}

int main(){
  int aaa[10000];
  int ans = 900000;
  while(true){
    cin >> n;
    if(n == 0)break;
    ans = 90000;
    for(int i = 0; i < n; i++){
      cin >> aaa[i];
    }
    for(int i = 0; i < n-1; i++){
      int temp = aaa[i];
      for(int j = 1; j < 4; j++){
        aaa[i] = j;
        ans = min(ans,calc(aaa,i));
      }
      aaa[i] = temp;
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3052
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
#define mod 1000000007
int i,j,k,l;
static const int MAX_N=10e5;
int ans=0;
int A[2],B[2];
int main(void){
	int N;
		cin >> N;
	rep_(i,1,N){
		int p;
			cin >> p;
		if(p!=i){
			ans++;
			if(ans==1){A[0]=i;B[0]=p;}
			else if(ans==2){A[1]=i;B[1]=p;}
		}
	}
	if(ans==0){puts("YES");}
	else if(ans==2 &&(A[0]==B[1] && A[1]==B[0])){
		puts("YES");}
	else {puts("NO");}
	return 0;
}


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

int main() {
  int n;
  cin>>n;
  long long int L[n+1];
  L[0]=2;
  L[1]=1;
  for(int i=2;i<n+1;i++)
    L[i]=L[i-1]+L[i-2];
  cout<<L[n];
}

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

using namespace std;

int main(){
	long long int n,d;
	cin>>n>>d;
	long long int count=0;
	for(long long int i=0;i<n;i++){
		long long int x,y;
		cin>>x>>y;
		long long int dis=x*x+y*y;
		if(dis<=d*d){
			count++;
		}
	}
	cout<<count<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main(){
	int N,K,answer=0;
	int I[50]={0};
	cin >> N >> K;
	for(int i=0;i<N;i++){
		cin >> I[i];
	}
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			int memo=min(I[j],I[j+1]);
			I[j]=max(I[j],I[j+1]);
			I[j+1]=memo;
		}
	}
	
	for(int i=0;i<K;i++){
		answer+=I[i];
	}
	
	cout << answer << endl;
	return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n, a, b;
  int ans = 0;
  cin >> n >> a >> b;
  vector<int> x(n);
  arep(i, x) cin >> i;

  rep(i, 1, n) 
    ans += min(a * (x[i] - x[i - 1]), b);

  cout << ans << '\n';
  return 0;
}

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

  
  int a,b,c,d;

  cin>>a>>b>>c>>d;

  if(abs(a-c)<=d||(abs(a-b)<=d&&abs(c-b)<=d)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }

  return 0;

}


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

template <const long long M>
class mint {
   private:
    long long x;

   public:
    constexpr mint(long long x = 0) : x((x % M + M) % M) {}
    constexpr long long value() { return x; }
    constexpr mint operator-() const { return mint(-x); }
    constexpr mint &operator+=(const mint &a) {
        if ((x += a.x) >= M) x -= M;
        return *this;
    }
    constexpr mint &operator-=(const mint &a) {
        if ((x += M - a.x) >= M) x -= M;
        return *this;
    }
    constexpr mint &operator*=(const mint &a) {
        (x *= a.x) %= M;
        return *this;
    }
    constexpr mint &operator/=(const mint &a) { return (*this) *= a.inv(); }
    constexpr mint operator+(const mint &a) const {
        mint res(*this);
        return res += a;
    }
    constexpr mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }
    constexpr mint operator*(const mint &a) const {
        mint res(*this);
        return res *= a;
    }
    constexpr mint operator/(const mint &a) const {
        mint res(*this);
        return res /= a;
    }
    constexpr mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    constexpr mint inv() const { return pow(M - 2); }
    constexpr bool operator==(const mint &a) const { return x == a.x; }
    constexpr bool operator!=(const mint &a) const { return x != a.x; }
    friend istream &operator>>(istream &in, mint &a) {
        in >> a.x;
        if (a.x < 0) a.x += M;
        a.x %= M;
        return in;
    }
    friend ostream &operator<<(ostream &out, const mint &a) {
        out << a.x;
        return out;
    }
};

mint<1000000007> cntways(int x) {
    vector<mint<1000000007>> DP(x + 1);
    DP[0] = 1;
    DP[1] = 1;
    for (int i = 2; i <= x; i++) {
        DP[i] = DP[i - 1] + DP[i - 2];
    }
    return DP[x];
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<bool> A(N + 1, false);
    for (int i = 1; i <= M; i++) {
        int a;
        cin >> a;
        A[a] = true;
    }
    mint<1000000007> ans = 0;
    if (A[N] == true) {
        cout << ans << endl;
        return 0;
    }
    for (int i = 0; i < N; i++) {
        if (A[i] == true && A[i + 1] == true) {
            cout << ans << endl;
            return 0;
        }
    }
    ans = 1;
    int cnt = 0;
    for (int i = 0; i <= N; i++) {
        if (i == N || A[i + 1] == true) {
            ans *= cntways(cnt);
            cnt = 0;
            i++;
        } else {
            cnt++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  int ans=0;
   for (int i=0; i<N-2; i++){
    if (S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C' ) ans=ans+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256