akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y){
  int r;
  if(x<y)swap(x,y);
  while(y>0){
    r=x%y;
    x=y;
    y=r;
  }
  return x;
}

int main(){
  int ans,x,y,i=1;
  cin>>x>>y;
  ans=gcd(x,y);
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 3100
def solve(y, m, d)
    if y > 2019
        return false
    end
    if y == 2019 && m > 4
        return false
    end
    if y == 2019 && m == 4 && d > 30
        return false
    end
    return true
end

y, m, d = gets.split('/').map(&:to_i)
puts solve(y, m, d) ? "Heisei" : "TBD"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int A,B,C;cin>>A>>B>>C;
  
  if(B+C>=A){
  cout<<B+C-A<<endl;
  }
  else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 3636
n,t=map(int,input().split())
a=list(map(int,input().split()))
kau=1
uru=0
cost=0
min_a=a[0]
min_count=0
max_sa=0
for i in range(1,n):
  if a[i]<min_a:
    min_a=a[i]
    if uru!=0:
      cost+=min(kau,uru)
    kau=1
    uru=0
  elif a[i]==min_a:
    kau+=1
  elif a[i]-min_a>max_sa:
    max_sa=a[i]-min_a
    cost=0
    uru=1
  elif a[i]-min_a==max_sa:
    uru+=1
if uru!=0:
  cost+=min(kau,uru)
print(cost)

Measured memory_bytes: 15060
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;

int main() {
    string S;
    cin>>S;
    
    if(S[0]==S[1]&&S[1]==S[2]&&S[0]=='R'){
        cout<<3<<endl;
    }
    else if(S[0]==S[1]&&S[1]!=S[2]&&S[0]=='R'||S[0]!=S[1]&&S[1]==S[2]&&S[1]=='R'){
        cout<<2<<endl;
    }
    else if(S[0]==S[1]&&S[1]==S[2]&&S[1]=='S'){
            cout<<0<<endl;
        
    }
    else{
        cout<<1<<endl;
    }
}


Measured memory_bytes: 3624
def f(v):
    idx = [399, 799, 1199, 1599, 1999, 2399, 2799, 3199, 9999]
    for i, maxval in enumerate(idx):
        if v <= maxval: return i


def solve():
    N = int(input())
    colors = [0] * 9

    for i in [int(v) for v in input().split()]:
        colors[f(i)] += 1

    _cnt = len([c for c in colors[:-1] if c > 0])

    max_cnt = _cnt + colors[-1]
    min_cnt = 1 if _cnt == 0 else _cnt
    print(min_cnt, max_cnt)

solve()


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  
  int x,y,tmp,num,amari;

  scanf("%d%d",&x,&y);

  if( x < y){
    tmp = x;
    x = y;
    y = tmp;    
      }
  
  num = x%y;

  //numとyの最大公約数を求める。
  
  while(num != 0){
    amari  =  y % num;
    y = num;
    num = amari;
    if(amari ==0)break;
  }
  printf("%d\n",y);
  
  return 0;
}



Measured memory_bytes: 2144
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    if (y % 2) {cout << "No"; return 0;}
    if (y/2 >= x && 2*x >= y/2) cout << "Yes\n";
    else cout << "No";
}

Measured memory_bytes: 3132
#include <stdio.h>
main()
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if( x-r<0 || x+r>W || y-r<0 || y+r>H )
		printf("No\n", W, H, x, y, r);
	else
		printf("Yes\n", W, H, x, y, r);
				return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include<string>

using namespace std;

constexpr auto BASE = 998244353;

int N;
string b;

enum {R,G,B,CNUM};

int main()
{
	long long ans = 1;
	long long ans_min = 1;
	long long ans_max = 1;

	cin >> N;
	cin >> b;

	int ball_count[CNUM];
	for (int i = 0; i < CNUM; i++) {
		ball_count[i] = 0;
	}


	int tgt,opp1, opp2;
	for ( int i = 0; i < N*CNUM; i++) {
		if (b.at(i) == 'R') {
			tgt = R;
			opp1 = G;
			opp2 = B;
		}
		else if (b.at(i) == 'G') {
			tgt = G;
			opp1 = B;
			opp2 = R;

		}
		else{
			tgt = B;
			opp1 = R;
			opp2 = G;
		}

		if (ball_count[tgt] >= ball_count[opp1] && ball_count[tgt] >= ball_count[opp2]) {
			//min
			ans_min = (ans_min * (ball_count[tgt] - max(ball_count[opp1], ball_count[opp2]) + 1)) % BASE;
		}
		else if (ball_count[tgt] < ball_count[opp1] && ball_count[tgt] < ball_count[opp2]) {
			//max
			ans_max = (ans_max * (min(ball_count[opp1],ball_count[opp2]) - ball_count[tgt])) % BASE;
		}
		else {
			//center
		}

		ball_count[tgt]++;
	}



	ans = (ans_min * ans_max) % BASE;
	for (int i = 1; i < N + 1; i++) {
		ans = (ans * i) % BASE;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 900
import bisect
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
for i in range(1,N):
    A[i]+=A[i-1]
for i in range(1,M):
    B[i]+=B[i-1]

ans=bisect.bisect_right(B,K)
for i in range(0,N):
    if K>=A[i]:
        temp=i+1
        id=bisect.bisect_right(B,K-A[i])
        temp+=id
        ans=max(ans,temp)


print(ans)


Measured memory_bytes: 110960
def main():
    N = int(input())
    N_len = len(str(N))
    if N_len < 3:
        return print(0)
    from itertools import product
    ans_set = set()
    for k in range(3, N_len+1):
        ans_set = ans_set.union({s for s in product("753", repeat=k)
                                 if int("".join(s)) <= N and
                                 len(set(s) & set("753")) == 3})
    print(len(ans_set))


if __name__ == '__main__':
    main()


Measured memory_bytes: 8892
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	iv, _ := strconv.Atoi(scanString())
	return iv
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100001), 100001*100)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	n := scanInt()
	ans := 0
	cab, ca, cb := 0, 0, 0
	for i := 0; i < n; i++ {
		s := scanString()
		ans += strings.Count(s, "AB")
		if s[0] == 'B' && s[len(s)-1] == 'A' {
			cab++
		} else if s[0] == 'B' {
			cb++
		} else if s[len(s)-1] == 'A' {
			ca++
		}
	}
	if ca > 0 && cab > 0 {
		ca--
		ans++
	}
	if cb > 0 && cab > 0 {
		cb--
		ans++
	}
	if cab > 0 {
		ans += cab - 1
	}
	ans += min(ca, cb)
	fmt.Println(ans)
}


Measured memory_bytes: 768
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <vector>

namespace null_null {

using int64 = std::int_fast64_t;
using usize = std::size_t;

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

} // namespace null_null

#include <algorithm>
#include <cmath>
#include <iostream>
#include <utility>

namespace null_null {

void main_() {
  int64 N, L;
  std::cin >> N >> L;
  std::vector<int> v(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    v[i] = L + i;
    sum += v[i];
  }

  int ans = 1e9;
  int res = 0;
  for (int i = 0; i < N; i++) {
    int tmp = sum - v[i];
    int diff = std::abs(sum - tmp);
    if (ans > diff) {
      ans = diff;
      res = tmp;
    }
  }

  std::cout << res << std::endl;
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>

const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    string S;
    cin>>S;
    if(S=="AAA" || S=="BBB"){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}

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

#define println(msg) cout << msg << endl
#define yes_or_no(flag) if (flag) { println("Yes"); } else { println("No"); }
#define sort_vec(vec) sort(vec.begin(), vec.end())
#define rsort_vec(vec) sort(vec.rbegin(), vec.rend()) // greater<int>()

int main() {
  // 入力
  int W, H, N;
  cin >> W >> H >> N;

  vector<tuple<int, int, int>> d(N);
  for (int i = 0; i < N; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    d.at(i) = make_tuple(x, y, a);
  }
  
  // 計算
  int xmin = 0;
  int xmax = W;
  int ymin = 0;
  int ymax = H;
  
  for (int i = 0; i < N; i++) {
    int a = get<2>(d.at(i));
    switch (a) {
      case 1: // x < xi
        if (xmin < get<0>(d.at(i)))
          xmin = get<0>(d.at(i));
        break;
      case 2: // x > xi
        if (xmax > get<0>(d.at(i)))
          xmax = get<0>(d.at(i));
        break;
      case 3: // y < yi
        if (ymin < get<1>(d.at(i)))
          ymin = get<1>(d.at(i));
        break;
      case 4: // y > yi
        if (ymax > get<1>(d.at(i)))
          ymax = get<1>(d.at(i));
        break;
    }
  }

  // 出力
  if (xmin > xmax || ymin > ymax) {
	println(0);
  } else {
    println((xmax - xmin) * (ymax - ymin));
  }
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Solve();
        }

        void Solve()
        {
            var line = Console.ReadLine();
            if(line[0]==line[1]&& line[1]==line[2] ||
                line[1] == line[2] && line[2] == line[3])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
#if defined(LOCAL)
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#endif
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <iostream>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <limits>
#include <numeric>
#include <queue>
#include <memory>

using namespace std;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ii = pair<int,int>; using lu = unsigned long long; using l = long long;
using vs = vector<string>; using vii = vector<ii>;
using vl = vector<l>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>; using sl = unordered_set<l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; const double PI = M_PI;
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));
// TODO: fix parsing for atcoder beta https://beta.atcoder.jp/contests/abc110/tasks/abc110_a
void solve(istream& in, ostream& out);
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  tst::test_init(argc, argv);
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  tst::maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}
const l MOD = e9 + 7; // end of template

void solve(istream& in, ostream& out) {
  l a, b, c; in >> a >> b >> c;
  if (b > a) swap(a, b);
  if (c > a) swap(a, c);
  out << a * 10 + b + c << lf;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

int main(){
    ll n;
    cin>>n;
    ll A[n];
    loop(i,0,n){
        cin>>A[i];
    }
    ll cost[n] = {0};
    cost[1] = abs(A[1]-A[0]);
    loop(i,2,n){
        cost[i] = min(cost[i-1]+abs(A[i-1]-A[i]), cost[i-2] + abs(A[i-2]-A[i]));
    }
    cout<<cost[n-1]<<endl;
    return 0;
}

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

bool any(const vector<int>& xs, int left, int right) {
  for (int i = left; i < right; ++i) if (xs[i]) return true;
  return false;
}

int accumulate(const vector<int>& xs, int left, int right) {
  int acc = 0;
  for (int i = left; i < right; ++i) acc += xs[i];
  return acc;
}

int main() {
  int N;
  cin >> N;
  vector<int> xs(4801);
  for (int i = 1; i <= N; ++i) {
    int a;
    cin >> a;
    ++xs[a];
  }
  int n_colored = 0;
  for (int i = 0; i < 8; ++i) {
    const int left = 400 * i;
    const int right = left + 400;
    n_colored += any(xs, left, right) ? 1 : 0;
  }
  const int n_wildcard = accumulate(xs, 3200, 4801);
  cout << max(1, n_colored) << " " << (n_colored + n_wildcard) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for(int i = 0; i<n; ++i)
using namespace std;

int main(){
  string n;
  bool flag = 0;
  cin >> n;
  rep(i, 2){
    if(n[i]==n[i+1])  if(n[i]==n[i+2])  flag = 1;
    if(flag == 1) break;
  }
  if(flag == 1) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline().rstrip())
HList = list(map(int,sys.stdin.readline().rstrip().split()))

hbefore=HList[0]
canDown=True
for i in range(1,N):
  if HList[i]-hbefore >0:
    canDown=True
  elif HList[i]-hbefore ==0:
    hbefore=HList[i]
    continue
  elif HList[i]-hbefore ==-1 and canDown:
    canDown=False    
  else:
    print("No")
    exit()
 
  hbefore=HList[i]
  
print("Yes")
  

Measured memory_bytes: 63984
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;


int main()
{
    int d,n;
    cin >> d >> n;
    if(n == 100) n += 1;

    cout << int(pow(100,d)*n) << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int i,n,t,a,b,c,cnt=0,s,r;
    scanf("%d%d%d",&n,&a,&b);
    for(i=1;i<=n;i++)
    {
        t=i;
        s=0;
        while(t!=0)
        {
            r=t%10;
            s=s+r;
            t=t/10;
        }
        if(s>=a && s<=b)
        {
          cnt=cnt+i;  
        }
    }
    printf("%d\n",cnt);
    return 0;
    
}


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

int main()
{
string s ;
cin >> s ;
ll r=0,b=0;
rep(i,s.size()){
  if(s[i]=='0')r+=2;
  else if(s[i]=='2')b+=2;
  else {r++;b++;}
}
vector<ll> rr,bb;
rr.push_back(0);
bb.push_back(0);
rep(i,s.size()){
  if(s[i]=='0'){
    rr.push_back(rr.back()+2);
    bb.push_back(bb.back());
  }
  if(s[i]=='1'){
    rr.push_back(rr.back()+1);
    bb.push_back(bb.back()+1);
  }
  if(s[i]=='2'){
    bb.push_back(bb.back()+2);
    rr.push_back(rr.back());
  }
}
while(rr.size()!=2*s.size()+1)rr.push_back(rr.back());
while(bb.size()!=2*s.size()+1)bb.push_back(bb.back());
vector<vector<ll>> v(s.size()*2, vector<ll>(r+1,0) );
if(s[0]=='0')v[0][1]=1;
if(s[0]=='1'){v[0][0]=1;v[0][1]=1;}
if(s[0]=='2')v[0][0]=1;
rep(i,s.size()*2-1){
  rep(j,r+1){
    if(i+2-j<=bb[i+2]){
      v[i+1][j]+=v[i][j];
      v[i+1][j]%=mo;
    }
    if(j+1<=rr[i+2]){
      v[i+1][j+1]+=v[i][j];
      v[i+1][j+1]%=mo;
    }
  }
}
cout << v[s.size()*2-1][r] << endl;
return 0;
}

Measured memory_bytes: 125312
#include<stdio.h>

int main()
{
	int S,h,m,s,a;
	scanf("%d",&S);
	h=S/(60*60); a=S%(60*60);
	m=a/60; s=a%60;
	printf("%d:%d:%d\n",h,m,s);

	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF=1e18,MOD=1e9+7;
int main(){
  ll n;
  vector<ll>a(5);
  cin>>n;
  for(int i=0;i<5;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  ll ans=0;
  if(n>a[0]){
    ans=n/a[0];
    if(n%a[0]==0)ans--;
  }
  ans+=5;
  cout<<ans<<endl;
}

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

const int mod=998244353;
const int N=3005;
int n,x,f[N][2*N],dp[N][2*N];
int fac[N],infac[N],inv[N];

namespace MATHEMATICS
{
	int add(int x,int y)
	{
		int ret=x+y;
		if(ret>=mod) ret-=mod;
		return ret;
	}
	int mi(int x,int y)
	{
		int ret=x-y;
		if(x<0) x+=mod;
		return ret;
	}
	
	void inc(int &x,int y)
	{
		x+=y;
		if(x>=mod) x-=mod;
	}
	void dec(int &x,int y)
	{
		x-=y;
		if(x<0) x+=mod;
	}
	
	int mul(int x,int y)
	{
		return 1LL*x*y%mod;
	}
	int F_p(int x,int y)
	{
		int bas=x,ret=1;
		while(y)
		{
			if(y&1) ret=mul(ret,bas);
			bas=mul(bas,bas);
			y>>=1;
		}
		return ret;
	}
}
using namespace MATHEMATICS;

int C(int x,int y)
{
	return mul(fac[x],mul(infac[y],infac[x-y]));
}
void prework()
{
	int i,j;f[0][0]=1;
	for(i=1;i<=n;++i)
		for(j=i;j<=2*i;++j)
			f[i][j]=add(f[i-1][j-1],f[i-1][j-2]);
	
	fac[0]=1;for(i=1;i<=n;++i) fac[i]=mul(fac[i-1],i);
	inv[1]=1;for(i=2;i<=n;++i) inv[i]=mul(inv[mod%i],mod-mod/i);
	infac[0]=1;for(i=1;i<=n;++i) infac[i]=mul(infac[i-1],inv[i]);
}

void DP()
{
	int i,j,k;dp[0][0]=1;
	for(i=1;i<=n;++i)
		for(j=i;j<=2*i;++j)
		{
			if(j<x-1) dp[i][j]=f[i][j];
			else
			{
				if((j&1)==(x&1)) dp[i][j]=0;
				else
				{
					int len=(j-(x-1))>>1;
					if(2*len>i||4*len>j)
					{
						if((x&1)&&(i<<1)==j) dp[i][j]=1;
						else dp[i][j]=0;
					}
					else dp[i][j]=f[i-2*len][j-4*len];
				}
			}
		}
}

void work()
{
	int i,j,ans=0;
	for(i=0;i<=n;++i)
		for(j=i;j<=2*i;++j)
			inc(ans,mul(dp[i][j],C(n,i)));
	printf("%d\n",ans);
}

int main()
{
	scanf("%d%d",&n,&x);
	prework();DP();work();
	return 0;
}

Measured memory_bytes: 139008
S = input()
list = ["A","C", "G", "T"]

result = []
for i in range(len(S)):
    tmp = 0
    for j in range(len(S)-i):
        if S[j+i] in list:
            tmp += 1
        else:
            break
    result.append(tmp)
print(max(result))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << "," << el.second << "] "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,K;
vector<ll> H;

void input(){
    #ifdef __LOCAL
        fs::path path_to_file = __FILE__;
        fs::path input,output;
        input = output = path_to_file.parent_path();
        input += string("/input/") + string(path_to_file.stem()) + string(".txt");
        output += string("/output/") + string(path_to_file.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N >> K;
    H = fetch_vec<ll>(N);
}

void solve(){
    input();
    VSORT(H)
    if(K>=N) cout << 0 << endl;
    else{
        ll ans = accumulate(H.begin(),H.end()-K,0LL);
        cout << ans << endl;
    }
    
}

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


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int n,a,i,count=0,count2=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(a%4==0)count++;
    else if(a%2==0)count2++;
  }
  if(2*count+1>=n)puts("Yes");
  else if(2*count+count2>=n)puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}


int main(){
    int n,l;
    cin>>n>>l;
    string s[n];
    rep(i,0,n) cin>>s[i];
    sort(s,s+n);
    rep(i,0,n) cout<<s[i];
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int n = s.size();
    ll acc = 0;
    ll tot = 0;
    rep(i,0,n) {
        if(s[i]=='W') tot+=acc;
        else ++acc;
    }
    cout<<tot<<"\n";
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = 3.141592653589;
double ans;

int main(){
  double a, b, c;
  string s, t;
  cin >> a;
  printf("%lf\n", a * 2 * PI);
}

Measured memory_bytes: 3816
/*Coded by::
    **Avinash Tiwary**
    **BE/10298/2015**
    **Production Engineer**
    **Producing <code>**
*/
#include<bits/stdc++.h>
#define buf ios_base::sync_with_stdio (0), cin.tie (0)
typedef long long ll;
typedef double dob;
#define MAX 50010
#define M5 200009
#define M6 2000009
#define M 1000000007
#define inf LLONG_MAX
using namespace std;
typedef vector<ll> V;
typedef queue<ll > Q;
typedef stack<ll> S;
typedef pair<dob,ll> P;
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
ll fac[M6],not_prime[M6],ar[M6],br[M6];
ll power(ll x,ll n)
{   if(n==0) return 1;
    else if(n%2 == 0) return power((x*x)%M,n/2);
    else return (x*power((x*x)%M,(n-1)/2))%M;
}
void fact(){
    fac[0]=1;
    for(ll i=1;i<M6;i++) fac[i]=(i*fac[i-1])%M;
}
void sieve(){
    not_prime[1]=1; not_prime[0]=1;
    for(ll p=2;p*p<M6;p++){
        if(!not_prime[p]){
            for(ll i=p*2;i<=M6;i+=p) not_prime[i]=1;
        }
    }
}
ll modi(ll a, ll m){
    ll m0 = m, t, q; ll x0 = 0, x1 = 1;
    if (m == 1) return 0;
    while (a > 1){  q = a / m; t = m; m = a % m, a = t;t = x0;x0 = x1 - q * x0; x1 = t;}
    if (x1 < 0) x1 += m0;return x1;
}
V g[M5];
ll flag=1;
void dfs(ll cur,ll par){
    for(ll u:g[cur]){
        if(u==par) continue;
        if(ar[u]==-1){
            ar[u]=1-ar[cur];
            dfs(u,cur);
        }
        else{
            if(ar[u]==ar[cur]) flag=0;
        }
    }
}
int main(){
    buf; 
    //sieve(); 
    //fact();
    ll i,j,k,test,t,ans,a,b,n,m,c,d,q,l; string s1,s2,s3;
    //cin>>test;
    test=1;
    while(test--){
        cin>>n>>m;
        for(i=1;i<=m;i++){
            cin>>a>>b; g[a].pb(b); g[b].pb(a);
        }
        memset(ar,-1,sizeof(ar));
        ar[1]=0;
        dfs(1,0);
        if(flag){
            ans=0;
            for(i=1;i<=n;i++) if(ar[i]) ans++;  
            cout<<ans*(n-ans)-m;
        }
        else{
            cout<<n*(n-1)/2-m;
        }
    }
    return 0;
}

Measured memory_bytes: 29440
#include<stdio.h>
int main()
{
    int a,b,c,max,mid;
    scanf("%d%d%d",&a,&b,&c);
    if(a>=1&&a<=10000&&b>=1&&b<=10000&&c>=1&&c<=10000)
    {
        if(a<b&&a<c)
        {
            max=a;
            if(b<c)
            {
                mid=b;
            }
            else
            {
                mid=c;
            }
        }

        else if(b<a&&b<c)
        {
            max=b;
            if(a<c)
            {
                mid=a;
            }
            else
            {
                mid=c;
            }
        }

       else if(c<b&&c<a)
        {
            max=c;
            if(b<a)
            {
                mid=b;
            }
            else
            {
                mid=a;
            }
        }
        else if(a==b&&a==c&&b==c)
		{
			max=a;
			mid=a;
		}
		else if(a==b&&a!=c)
		{
			if(a<c)
			{
				max=a;
				mid=a;
			}
			else
			{
				max=c;
				mid=a;
			}
		}
	else if(b==c&&b!=a)
		{
			if(b<a)
			{
				max=b;
				mid=b;
			}
			else
			{
				max=a;
				mid=b;
			}
		}
     else if(a==c&&a!=b)
		{
			if(b<a)
			{
				max=b;
				mid=a;
			}
			else
			{
				max=a;
				mid=a;
			}
		}
		printf("%d",max+mid);
    }
    return 0;
}


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

#define forl(V, N) for(int V = 0; V < N; V++)
#define forll(V, S, E) for(int V = S; V < E; V++)
#define forlc(V, S, E, I) for(int V = S; V < E; V += I)
#define fore(E, X) for(auto &E:X)
#define print(X) cout << X
#define printsp(X) cout << X << " "
#define println(X) cout << X << endl
#define rem(X) X.top(); X.pop()
#define mid(A, B) ((A+B) / 2)
#define setmin(A, B) A = min(A, B)
#define graph unordered_map<int, unordered_set<int>>
#define vi vector<int>
#define pb push_back
#define ll long long

int N, K;
int H[100101];
int DP[100101];

int main() {
    cin >> N >> K;
    forl(i, N) cin >> H[i];
    fill_n(DP, 100000, INT_MAX);
    DP[0] = 0;
    forl(i, N-1) {
        for(int j = i+1; j < i+K+1; j++) setmin(DP[j], abs(H[i]-H[j]) + DP[i]);
    }
    println(DP[N-1]);
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include<iostream>
#include<sstream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<math.h>
#include<iterator>

using namespace std;

int main(){
  string s;
  cin >> s;
  for(int i=0;i<4;i++)cout << s[i];
  cout <<" ";
  for(int i=4;i<12;i++)cout << s[i];
  cout <<endl;
      return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}


int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<char> v;
    for(int i=0; i<s.size(); ++i) {
        if (s[i] != s[i+1]) {
            v.pb(s[i]);
        }
    }
    cout << v.size() << "\n";
}


Measured memory_bytes: 640
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define rep(i,a,b) for(int i = a ; i <= b ; i++)
#define per(i,a,b) for(int i = b ; i >= a ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const LL INF = 1e18;
const int mod = 2010;
const int maxn = 2e5 + 7;

int a[maxn];

bool cmp(int a,int b) {
    return a > b;
}

int main() {
    LL n , k;
    while(cin >> n >> k) {
        LL temp = n % k;
        cout << min(k - temp , temp) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <random>
//#include <chrono>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define MotoHaiyaku ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    MotoHaiyaku
    ll h,w,k,ans=0,t=0;
    string s[10];
    cin>>h>>w>>k;
    rep(i,h) cin>>s[i];
    rep(i,h) rep(j,w) if(s[i][j]=='#') t++;
    rep(i,1<<h)
    {
        rep(j,1<<w)
        {
            ll a=i,b=j;
            set<pair<ll,ll> > st;
            rep(x,h)
            {
                if(a%2)
                {
                    rep(y,w)
                    {
                        if(s[x][y]=='#') st.insert(mp(x,y));
                    }
                }
                a/=2;
            }
            rep(y,w)
            {
                if(b%2)
                {
                    rep(x,h)
                    {
                        if(s[x][y]=='#') st.insert(mp(x,y));
                    }
                }
                b/=2;
            }
            if(t-st.size()==k) ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
        int a, b, c, t;
        scanf("%d %d %d", &a, &b, &c);

        if(a>b){
                t = a;
                a = b;
                b = t;
        }
        if(b>c){
                t = c;
                c = b;
                b = t;
        }
        if(a>b){
                t = a;
                a = b;
                b = t;
        }
        printf("%d %d %d\n", a, b, c);
        return 0;
}


Measured memory_bytes: 2064
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//Shredding Company
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int t = sc.nextInt();
			String s = sc.next();
			if(t==0&&"0".equals(s))break;
			int max = -1;
			List<String> piece = new ArrayList<String>();
			boolean col = false;
			int n = s.length()-1;
			for(int i=0;i<1<<n;i++){
				int p = 0;
				int sum = 0;
				List<String> sub = new ArrayList<String>();
				for(int j=0;j<n;j++){
					if((i>>j&1)==0)continue;
					String u = s.substring(p, j+1);
					sub.add(u);
					sum += Integer.parseInt(u);
					p = j+1;
				}
				sub.add(s.substring(p));
				sum += Integer.parseInt(s.substring(p));
				if(sum<=t&&max<sum){
					max = sum; col = false; piece = sub;
				}
				else if(sum==max){
					col = true;
				}
			}
			if(max==-1)System.out.println("error");
			else if(col)System.out.println("rejected");
			else{
				System.out.print(max+" ");
				for(int i=0;i<piece.size();i++)System.out.print(piece.get(i)+(i==piece.size()-1?"\n":" "));
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n, a, b;
    cin>>n>>a>>b;

    ll ans = 0;
    if((b - a) % 2 == 0){
        ans += (b - a) / 2;
    }else{
        ans += min(a-1, n-b) + (b - a + 1) / 2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

l = [a1, b1, a2, b2, a3, b3]
flag = True

for i in range(1, 5):
    if not(1 <= l.count(i) and l.count(i) <= 2):
        flag = False

if flag:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
//by azidoazideazide(c2n14)
//
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
using ll=long long;

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n; string s;
	cin>>n>>s;
	if(n<3200) cout<<"red\n";
	else cout<<s<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    static int top = 0;
    static int[] num = new int[1000];

    public static void push(int x){

        num[++top] = x;
    }

    public static int pop(){

        top--;
        return num[top+1];
    }

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();

        String[] strings = str.split(" ");
        for (int i=0; i<strings.length; i++){
            if (strings[i].equals("+")){
                int a = pop();
                int b = pop();
                push(a+b);
            }
            else if (strings[i].equals("-")){
                int a = pop();
                int b = pop();
                push(b-a);
            }
            else if (strings[i].equals("*")){
                int a = pop();
                int b = pop();
                push(a*b);
            }
            else {
                push(Integer.parseInt(strings[i]));
            }
        }

        System.out.println(pop());
    }
}

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

int main(){
    const int n = 5;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    vector<int> mod;
    
    rep(i, n){
        if(a[i]%10!=0) mod.push_back(a[i]%10);
    }
    
    int minv = 10;
    rep(i,mod.size()){
        minv = min(minv,mod[i]);
    }
    
    int sum = 0;
    rep(i, n){
        if(a[i]%10==0) sum += a[i];
        else sum += (a[i]/10+1)*10;
    }
    
    cout << sum - (10 - minv);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
double distance(double x, double y);
int kaijo(int n);
int main(){
    int n;
    scanf("%d",&n);
    double x[10];
    double y[10];
    int i;
    for(i=1;i<=n;i++){
        scanf("%lf %lf",&x[i],&y[i]);
    }
    int j;
    int roop;
    roop = kaijo(n)/kaijo(n-1);
    int a =kaijo(n);
    double dis=0;
    for(i=1;i<=n;i++){
        for(j=i;j<=n;j++){
            dis = dis + distance(x[j]-x[i],y[j]-y[i]);
        }
    }
    double ans;
    //ans =(n-1)*kaijo(n)*dis/n/kaijo(n);
    ans =(n-1)*dis/(n+n*(n-3)/2);
    printf("%lf\n",ans);
    return 0;
}
int kaijo(int n){
    int i=1;
    int sum =1;
    for(i=1;i<=n;i++){
        sum = sum+i;
    }
    return sum;
}
double distance(double x, double y){
    return sqrt(x*x+y*y);
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

string s;
int n;
bool f = 0;

void dfs(int i){
    if (i == n){
        f = 1;
        return;
    }
    if (s.substr(i,5) == "dream") dfs(i+5);
    if (s.substr(i,7) == "dreamer") dfs(i+7);
    if (s.substr(i,5) == "erase") dfs(i+5);
    if (s.substr(i,6) == "eraser") dfs(i+6);
}

int main() {
    cin >> s;
    n = s.length();

    dfs(0);

    cout << (f ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
main(){
	int a,b,c,d,x=0,y,i;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a>b){
	for(i=1;i<=b;i++){
		x=x+c;
	}
	for(i=1;i<=(a-b);i++){
		x=x+d;
	}}
	else{
		for(i=1;i<=a;i++){
			x=x+c;
	}}
	printf("%d",x);
	return 0;
}

	  

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

def same_tree(node_a, node_b):
    if node_a.root() == node_b.root():
        return True

def unite(node_a, node_b):
    root_a = node_a.root()
    root_b = node_b.root()
    if root_a == root_b:
        return
    if root_b.depth > root_a.depth:
        root_a, root_b = root_b, root_a
    root_b.is_root = False
    root_b.parent = root_a
    root_a.depth = max(root_a.depth, root_b.depth+1)

class Node:
    def __init__(self):
        self.is_root = True
        self.parent = None
        self.depth = 1
    
    def root(self):
        node = self
        while not node.is_root:
            node = node.parent
        return node

def main():
    V, E = map(int, input().split())

    nodes = [Node() for i in range(V)]

    stw = sorted([list(map(int, input().split())) for i in range(E)], key=lambda x:x[2])

    ans = 0
    for i in range(E):
        s, t, w = stw[i]
        if not same_tree(nodes[s], nodes[t]):
            unite(nodes[s], nodes[t])
            ans += w
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 30748
#include <stdio.h>
int main(void) {
    int n, i, ans;
    char abc[4] = "ABC\0";
    char s[51];
    scanf("%d", &n);
    scanf("%s", s);
    ans=0;
    for (i=0; i<n; i++) {
        if (s[i] == abc[0]) {
            i++;
            if (s[i] == abc[1]) {
                i++;
                if (s[i] == abc[2]) {
                    ans++;
                } else {
                    i--;
                }
            } else {
                i--;
            }
        }
    }
    
    printf("%d", ans);
    return 0; 
}

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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#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;

int main(int argc, char *argv[]) {
    ll x;
    cin >> x;

    ll cnt_11 = (x / 11) * 2;

    if (x % 11 == 0) MSG(cnt_11)
    else if (x % 11 <= 6) MSG(cnt_11 + 1)
    else MSG(cnt_11 + 2)

    return 0;
}


Measured memory_bytes: 256
/*
TEST
*/


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
    string S;
    cin >> S;

    // 後ろから解くかわりにすべての文字列を「左右反転」する
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    // 端から切っていく
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false; // 4 個の文字列たちどれかで divide できるか
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) { // d で divide できるか
                can2 = true;
                i += d.size(); // divide できたら i を進める
            }
        }
        if (!can2) { // divide できなかったら
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
const l=require("fs").readFileSync("/dev/stdin", "utf8").split("\n")
let i=0
while(true){
  let [h,w]=l[i++].split(" ").map(Number)
  if (!h&&!w)break
  let f=s=>`${(Array(w+1).join(s)).slice(0,w)}\n`
  let c=f("#.")
  console.log(`${`${c}${f(".#")}`.repeat(Math.floor(h/2))}${h%2!=0?c:""}`)
}


Measured memory_bytes: 16028
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
typedef long long ll;

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
	}
	int sum = 0, buf = 0;
	//bool m = true;
	for (int i = 0; i < N; i++) sum += a.at(i);
	cout << sum - N << endl;

}

Measured memory_bytes: 3624
n = int(input())
for i in range(1,n+1):
   x = i
   if x % 3 == 0:
        print('', i, end='')
   else:
        while True:
            if x % 10 == 3:
                print('', i, end='')
                break
            x //= 10
            if x == 0:
                break
print()

Measured memory_bytes: 8204
tap = input()

odd = tap[0:len(tap):2]
even = tap[1:len(tap):2]

if odd.count('R')+odd.count('U')+odd.count('D')==len(odd) and even.count('L')+even.count('U')+even.count('D')==len(even):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  string ss = "UNRESTORABLE";
  int i,j;
  int chk = 0;
  for(i=s.length()-1;i>=t.length()-1;i--){
    if(s[i]==t[t.length()-1]||s[i]=='?'){
      chk = 1;
      for(j=1;j<t.length();j++){
          if(!(s[i-j]==t[t.length()-j-1]||s[i-j]=='?'))chk=0;
      }
      if(chk==1){
        ss = s;
        for(j=0;j<t.length();j++){
          ss[i-j] = t[t.length()-j-1];
        }
        for(j=0;j<ss.length();j++){
          if(ss[j]=='?')ss[j]='a';
        }
        break;
      }
    }
  }
  cout << ss << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

// 二部グラフ判定
using Edge = pint;
using Graph = vector<vector<Edge>>;

// 入力
int N;
Graph G;

// resは答え
vector<int> res;

// vをcに塗る。pはvの親
void dfs(int v, int p, int c) {
    res[v] = c;
    for (auto e : G[v]) {
        if (e.first == p) continue;
        if (e.second & 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}

int main() {
    cin >> N;

    G.assign(N, vector<Edge>());

    for (int i = 0; i < N-1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    
    res.assign(N, 0);
    dfs(0, -1, 1);
    for (auto v : res) 
        cout << v << endl;

    return 0;
}

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

int main(){
  string str;
  cin >> str;
  char spell = 'p';
  for(int i=0; i<str.length(); i++){
    if (str[i] == spell){
      cout << "Bad" << endl;
      return 0;
    }else{
      spell = str[i];
    }
  }
  cout << "Good" << endl;
  return 0;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int t;

void dfs(int pos, vector<int>& d, vector<int>& f, vector<vector<int>>& a){
	d[pos] = t;
	rep(i,a.size()){
		if(a[pos][i] == 1 and d[i] == -1){
			t++;
			d[i] = t;
			dfs(i, d, f, a);
		}
	}
	t++;
	f[pos] = t;
}

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

	vector<vector<int>> a(n, vector<int>(n,0));
	rep(i,n){
		int from;
		int m;
		cin >> from >> m;
		from--;
		rep(j,m){
			int to;
			cin >> to;
			to--;
			a[from][to] = 1;
		}
	}

	vector<int> d(n,-1), f(n);
	t = 1;
	rep(i,n){
		if(d[i] == -1) {
			dfs(i, d, f, a);
			t++;
		}
	}

	rep(i,n){
		cout << i + 1 << ' ' << d[i] << ' ' << f[i] << endl;
	}
}



Measured memory_bytes: 3152