akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    val A = Array(M) { readLine()!!.toInt() }

    val d = 1000000007
    val DP = LongArray(N + 1)

    DP[0] = 1
    DP[1] = 1
    A.forEach {
        DP[it] = -1
    }
    for (i in 2 until DP.size) {
        if (DP[i] == -1L) {
            continue
        }
        when {
            DP[i - 1] != -1L && DP[i - 2] != -1L -> DP[i] = (DP[i - 1] + DP[i - 2]) % d
            DP[i - 1] != -1L && DP[i - 2] == -1L -> DP[i] = DP[i - 1] % d
            DP[i - 1] == -1L && DP[i - 2] != -1L -> DP[i] = DP[i - 2] % d
            DP[i - 1] == -1L && DP[i - 2] == -1L -> {
                println(0)
                return
            }
        }
//        DP.joinToString(separator = ",").let(::println)
    }
    println(DP[N])
}


Measured memory_bytes: 41260
#include <iostream>
#include <vector>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,q; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    int cnt = 0;
    cin >> q;
    for(int i = 0; i < q; ++i){
        int x; cin >> x;
        for(int num:a){
            if(num == x){
                cnt++;
                break;
            }

        }
    }
    cout << cnt << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
int n;
vector<vector<int>> p;
vector<ll> c, d;
int id = 0;
ll score = 0;
struct N {
  int i, from;
  int d;
};

bool operator<(const N &l, const N &r) {
  return l.d < r.d;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> n;
  c.resize(n);
  p.resize(n);
  d.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    p[a].push_back(b);
    p[b].push_back(a);
  }
  for (int i = 0; i < n; i++) cin >> c[i];
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  int root = 0;
  for (int i = 1; i < n; i++) {
    if (p[i].size() > p[root].size()) {
      root = i;
    }
  }
  multiset<N> q;
  q.insert(N{root, -1, 0});
  while (q.size() > 0) {
    auto now = *q.begin();
    q.erase(q.begin());
    if (now.i != root)
      score += c[id];
    d[now.i] = c[id++];

    for (auto &j : p[now.i]) {
      if (now.from == j) continue;
      q.insert(N{j, now.i, now.d + 1});
    }
  }
  cout << score << endl;
  cout << d[0];
  for (int i = 1; i < n; i++) cout << " " << d[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 1664
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]
import heapq

L = []
R = []
pop = heapq.heappop
push = heapq.heappush
A, B, C = 0, 0, 0

def nasu(a):
  global A
  global C
  if len(R) == 0:
    push(R, a)
    C = a
    return
  if len(L) == 0:
    r = pop(R)
    push(L, -min(a, r))
    push(R, max(a, r))
    A += abs(a - r)
    C = min(a, r)
    return
  if len(L) < len(R):
    r = pop(R)
    l = -pop(L)
    push(L, -l)
    push(L, -min(a, r))
    push(R, max(a, r))
    A += abs(a - r)
    if a < l:
      C = l
    elif a < r:
      C = a
    return
  l = -pop(L)
  r = pop(R)
  if l <= a and a <= r:
    push(L, -l)
    push(R, r)
    push(R, a)
    C = a
  elif a < l:
    push(L, -a)
    push(R, r)
    push(R, l)
    A += abs(a - l)
    C = l
  else:
    push(L, -l)
    push(R, a)
    push(R, r)
    A += abs(a - r)
    C = r

for q in Query:
  if q[0] == 1:
    nasu(q[1])
    B += q[2]
  if q[0] == 2:
    print(C, A + B)
    

Measured memory_bytes: 56724
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>

namespace TokorotenLab
{
    /*
    Arguments:
        Search range: [begin, end)
        Target function: f(x)
    Requirement:
        f(x) => { false, ..., false, true, ..., true }
    Judge:
        true_bound == begin => All f(x) are true
        true_bound == end => All f(x) are false
    */
    std::pair<long long, long long> binary_search(long long begin, long long end, std::function<bool(long long)> f)
    {
        long long false_bound = begin - 1LL; // ( ..., false_bound] => false
        long long true_bound = end; // [true_bound, ... ) => true
        long long x;

        while(true_bound - false_bound > 1LL)
        {
            x = false_bound + (true_bound - false_bound) / 2LL;
            if(f(x))
            {
                true_bound = x;
            }
            else
            {
                false_bound = x;
            }
        }

        return std::make_pair(false_bound, true_bound);
    }
}

using namespace std;

signed main()
{
    int n, m;
    vector<int> gate;

    cin >> n >> m;

    gate.resize(n + 2);

    for(int i = 0; i < m; ++i) {
        int l, r;
        cin >> l >> r;
        ++gate[l];
        --gate[r + 1];
    }

    for(int i = 2; i <= n + 1; ++i) {
        gate[i] += gate[i - 1];
    }

    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        if(gate[i] == m) {
            ++ans;
        }
        //cout << gate[i] << " ";
    }
    //cout << endl;
    //
    
    cout << ans << endl;

    return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  string S;
  cin>>S;
  int k,ans=0,count=0;
  rep(i,S.size()){
    k=i;
    count=0;
    if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){
      
      while(S[k]=='A'||S[k]=='C'||S[k]=='G'||S[k]=='T'){
	count++;
	k++;
	
      }
      ans=max(ans,count);
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n)  FOR(i,0,n)

int main() {
	int n, k, a;
	int num[200002], tmp[200002], arg = 0, sum = 0;
	scanf("%d%d",&n,&k);
	REP(i,n+1) {
		num[i] = 0;
		tmp[i] = 0;
	}
	REP(i,n) {
		scanf("%d",&a);
		num[a]++;
	}
	//sort
	REP(i,n+1) tmp[num[i]]++;
	REP(i,n+1) REP(j,tmp[n-i]) num[arg++] = n-i;

	REP(i,k) sum += num[i];
	printf("%d",n - sum);
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int gcd(int a, int b)
{
	if (b == 0) {
		return a;
	} else {
		return gcd(b, a % b);
	}
}
/*int gcd(int a, int b)
{
	int r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}*/

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

	ans = gcd(A[0], A[1]);
	for (i = 2; i < N; i++) {
		ans = gcd(ans, A[i]);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
bool jud;
jud = false;
for (int i=0; i<N; i++){
  char s;
  cin >> s;
  if (s == 'Y'){
     jud = true;
  }   		
}
if (jud == true){
	cout << "Four" << endl;  
}
else{
    cout << "Three" << endl;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
#define MOD 1000000007
using namespace std;

int count(int n){

  int result=0;
  for (int i=5;;i*=5){
    if (n/i==0)break;
    else result+=((n/i)/2);
  }
  return result;
}

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

  if (n%2!=0)cout<<"0\n";
  else cout<<count(n)<<'\n';

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int X,Y;
    cin >> X >> Y;
    int Ans=0;
    if(X<=3){
        Ans+=(4-X)*100000;
    }
    if(Y<=3){
        Ans+=(4-Y)*100000;
    }
    if(X==1 && Y==1){
        Ans+=400000;
    }
    cout << Ans << endl;
    
    return 0;
}



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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		if(L == 0);
		String[]S = new String[N];
		for(int i = 0; i < N; i++) {
			S[i] = sc.next();
		}
		sc.close();
		Arrays.sort(S);
		StringBuilder sb = new StringBuilder();
		for(String t : S) {
			sb.append(t);
		}
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 24020
#include<bits/stdc++.h>
#define ll long long

using namespace std;

void DecimalToOctal(int decimalNum) {
   int octalNum = 0, placeValue = 1;
   int i = 0;
   string a;
   while (decimalNum != 0) {
      a.push_back('a'+ decimalNum%26);
      decimalNum /= 26;
      placeValue *= 10;
   }
   cout << a << endl;
}

int main(){
     ll n;
     cin >> n;
     string ans;
     while(n>0){
          n--;
          ans.push_back('a'+n%26);
          n /=26;
     }
     reverse(ans.begin(),ans.end());
     cout << ans;
} 


Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
  
 int num;
 scanf("%d",&num);
 
 if(num%10==3){
   printf("bon");
 }else if(num%10==0 ||num%10==1 ||num%10==6 ||num%10==8){
   printf("pon");
 }else{
   printf("hon");
 }
  
 return 0; 
}



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

int n, m;
vector<int> a;

int up(int p) {
	while (p > 0 && a[p] == a[p - 1])
		p--;
	return p;
}

int dn(int q) {
	while (q < n - 1 && a[q] == a[q + 1])
		q++;
	return q;
}

void ct(int p, int q, int p1, int q1) {
	while (q - q1 + p1 - p > 1 && p >= 0 && q < n) {
		m = min(m, n - q + p - 1);

		p--;
		q++;
		p1 = p;
		q1 = q;
		if (p >= 0 && q < n && a[p] == a[q]) {
			p = up(p);
			q = dn(q);
		}
	}
}

int main()
{
	cin >> n;

	while (n > 0) {
		a.resize(n);
		m = n;

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

		for (int i = 0; i < n; i++) {
			if (i > 0 && i < n - 1 && a[i - 1] != a[i] && a[i - 1] == a[i + 1])
				ct(up(i - 1), dn(i + 1), i, i + 1);
			else {
				if (i < n - 3 && a[i] != a[i + 1])
					ct(i, dn(i + 1), i, i + 1);
				if (i > 2 && a[i] != a[i - 1])
					ct(up(i - 1), i, i - 1, i);
			}
		}

		cout << m << endl;

		cin >> n;
	}

	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N, M, X;
    cin >> N >> M >> X;
    vec C(N);
    vector<vector<ll>> A(N, vector<ll>(M));
    loop(i, N)
    {
        cin >> C[i];
        loop(j, M) cin >> A[i][j];
    }
    ll ANS = 1e18;
    loop(bit, 1 << N)
    {
        vec check(M);
        bool Check = true;
        ll count = 0;
        loop(i, N)
        {
            if (flagon(bit, i))
            {
                count += C[i];
                loop(j, M) check[j] += A[i][j];
            }
        }
        loop(i, M) if (check[i] < X) Check = false;
        if (Check)
            ANS = min(ANS, count);
    }
    if (ANS != 1e18)
        putout(ANS);
    else
        putout(-1);
    return 0;
}


Measured memory_bytes: 3628
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;
const ll MOD = 1e9+7;
const ll INF = 1e18;


#define PB push_back
#define MP make_pair
#define F first
#define S second

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}

int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k<=a){
        cout << k << endl;
    }else if(k<=a+b){
        cout << a << endl;
    }else if(a+b<k){
        cout << 2*a+b-k << endl;
    }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;

   // cin>>t;
    while(t--)
    {
       int n,m,i;
       cin>>n;
       ll arr[n+1];
       for(i=0;i<n;i++)
        cin>>arr[i];
       ll mn=n+1;
       ll ans=0;
       for(i=0;i<n;i++)
        {
            if(arr[i]<=mn)
            {
                ++ans;
                mn=arr[i];
            }
        }
        cout<<ans;
    }
}


Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

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

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

int main() {
    int a,b;
    cin >> a >> b;
    for(int n = 0; n < 10000; ++n){
        int za = n*8/100;
        int zb = n*10/100;
        if(a == za && b == zb){
            cout << n << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 7
#define M 55
long long dp[M][1<<N][M][N];
int n,le,v[N],p[N],su;
double as;
int main()
{
	scanf("%d%d",&n,&le);
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);sort(v+1,v+n+1);
	for(int i=1;i<n;i++)p[i]=i;
	do{
		memset(dp,0,sizeof(dp));
		dp[0][0][v[n]][0]=1;
		for(int i=0;i<le;i++)
		for(int j=0;j<(1<<n-1);j++)
		for(int k=i;k<=le;k++)
		for(int l=0;l<n;l++)
		if(dp[i][j][k][l])
		for(int s=((1<<n-1)-1)^j;s<(1<<n-1);s=(s-1)&(((1<<n)-1)^j))
		{
			int fg=0;
			if(k>i)fg=1;
			int rs=k,rs2=l;
			for(int t=1;t<n;t++)if(s&(1<<t-1)){if(p[t]<l)fg=1;if(rs<(i+v[t]>le?le:i+v[t]))rs=(i+v[t]>le?le:i+v[t]),rs2=p[t];else if(rs==i+v[t]&&rs2<p[t])rs2=p[t];}
			if(fg)dp[i+1][j|s][rs][rs2]+=dp[i][j][k][l];
		}
		long long su=0;
		for(int i=0;i<n;i++)su+=dp[le][(1<<n-1)-1][le][i];
		double tp=su;
		for(int i=1;i<n;i++)tp/=le;
		as+=tp;
	}while(next_permutation(p+1,p+n));
	for(int i=1;i<n;i++)as/=i;
	printf("%.15lf\n",as);
}//

Measured memory_bytes: 21504
#include <bits/stdc++.h>
using namespace std;
struct point{double x;double y;};
int i,j,k,count1=0,count2=0;

int main(void){
    long long int a,b,c,minv;
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0){
        cout<<0<<endl;
        return 0;
    }else{
        minv=abs((a-(a/2))*b*c-(a/2)*b*c);
        minv=min(minv,abs(a*(b-(b/2))*c-a*(b/2)*c));
        minv=min(minv,abs(a*(c-(c/2))*b-a*(c/2)*b));
        cout<<minv<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

def swap(s,pos):
    s[pos]-=1
    s[pos+1]+=1
    print(s)
    if pos == n-2: return s
    if s[pos+2] == 0: swap(s,pos+1)
    return s


n = ip()                              #入力整数1つ
#left,n= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)



#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意

a = [2,1]
for i in range(n-1):
    a.append(a[i]+a[i+1])
print(a[n])


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

void solve()
{
    int n, x, t;
    cin >> n >> x >> t;
    int time = 0;
    while (n > 0)
    {
        n = n - x;
        time = time + t;
    }
    cout << time << "\n";
}

int main()
{
    solve();
}

Measured memory_bytes: 3632
using System;
namespace kozaiyApp
{
    public class A
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            string x = input[0];
            string y = input[1];
            string z = input[2];

            Console.WriteLine(z + ' ' + x + ' ' + y);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a[12]={0,2,0,1,0,1,0,0,1,0,1,0};
  int b,c;
  cin>>b>>c;
  if(a[b-1]==a[c-1]) {
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define sc second
typedef long long ll;
typedef pair<ll,ll> pll;

#define MAX_N 5000

const ll inf=1000000000000000000;
pll a[MAX_N];
ll dp[MAX_N][MAX_N+1];

bool cmp(pll a,pll b){
	return a.fi+a.sc<b.fi+b.sc;
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;++i) cin>>a[i].fi>>a[i].sc;
	sort(a,a+n,cmp);
	dp[0][0]=0;
	dp[0][1]=a[0].sc;
	for(int i=1;i<n;++i){
		dp[i][0]=0;
		if(a[i].fi>=dp[i-1][i]) dp[i][i+1]=dp[i-1][i]+a[i].sc;
		else dp[i][i+1]=inf;
		for(int j=1;j<=i;++j){
			if(a[i].fi>=dp[i-1][j-1]) dp[i][j]=min(dp[i-1][j],dp[i-1][j-1]+a[i].sc);
			else dp[i][j]=dp[i-1][j];
		}
	}
	for(int i=0;i<=n;++i) if(dp[n-1][i]>=inf){
		printf("%d\n",i-1);
		return 0;
	}
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 193920
#include <stdio.h>
using namespace std;
int n, m, i, j, k;
char c[5];
int main(){
	for(i = 1; i <= 3; i++){
		scanf("%c", &c[i]);
		if(c[2] == 'B') c[2] = 'R';
		else c[2] = 'B';
		printf("%c", c[i]);
	}
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
using std::cin;
using std::cout;
typedef long long ll;
const int Maxn = 4e5 + 5;
typedef double arr[Maxn];
//ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n;
arr a;
double d, ans;
int main()
{
	cin >> n >> a[1] >> d;
	n <<= 1;
	a[n] = a[1] + d * (n - 1);
	while (n > 0)
	{
		ans += (a[1] + a[n]) / 2;
		a[1] += (2 * a[1] + 5 * d) / n;
		a[n - 2] = a[n] - 2 * d;
		a[n - 2] += (2 * a[n - 2] + (2 * n - 1) * d) / n;
		d += 4 * d / n;
		n -= 2;
	}
	printf("%.10f\n", ans);
	return 0;
}
/*


1 2 3 4 5 6
9 15 21

x-2 x-1 x x+1 x+2

<=x x->x+2
x+1 x->xx+1x+2

x/n*2d+1/n*(2a+3d)
[2a+(3+2x)d]/n

a+[2a+(3+2x)d]/n
d+(2d+2d)/n
d+4d/n

n/2*2d+1/n*(3x+3d)
*/


Measured memory_bytes: 3328
n = int(input())
a = [int(i) for i in input().split()]

mod = 10**9+7

bin_a = []

for i in range(n):
    bin_a.append(format(a[i],'060b'))

ans = 0

for i in range(60):
    one = 0
    zero = 0
    for j in range(n):
        #print(bin_a[j])
        if bin_a[j][i] == '1':
            one += 1
        else:
            zero += 1
    #print(i,zero,one)
    ans += zero * one * (2**(59-i))
    
print(ans%mod)

Measured memory_bytes: 127760
#include <algorithm>
#include <cstring>
#include <cstdio>

using namespace std ;

const int N=1e6+10 ;

char s[N] ;
int a[N] ;
int n , k ;

int main ()
{
	int i ;
	scanf(" %d %s ",&k,s+1);
	n=strlen(s+1);
	for ( i=1 ; i<=n ; i++ )
		a[i]=s[i]-'A';
	for ( i=1 ; i<=n ; i++ )
		a[i]=(a[i]+k)%26;
	for ( i=1 ; i<=n ; i++ )
		putchar(a[i]+'A');
	return 0 ;
}


Measured memory_bytes: 2304
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long A, B, C;
    scan(A, B, C);
    if (B < A)
        swap(A, B);
    writeln(A <= C && C <= B ? "Yes" : "No");
}


Measured memory_bytes: 3652
from collections import Counter as cnt

N = int(input())
counter = {}
for i in range(N):
  s = input()
  if s not in counter:
    counter[s] = [1,0]
  else:
    counter[s][0] += 1
N = int(input())
for i in range(N):
  s = input()
  if s not in counter:
    counter[s] = [0,1]
  else:
    counter[s][1] += 1
counter[0] = [0,0]

print(max([b-r for b,r in counter.values()]))


Measured memory_bytes: 3316
import java.util.Scanner;


class Main {
	private static	int array[];
	
	public static void main(String args[]) {
		//実行処理
		run();
	}

	public static void run(){ 
		Scanner scanner = new Scanner(System.in);
		int  num = scanner.nextInt();//要素数
		array = new int[num];
		int cut;
		//配列作成同時にカウント
		for(int i = 0; i < num; i ++ ){
			array[i] = scanner.nextInt();
		}
		//ソート処理
		cut = partition(0, num - 1 );
		//出力呼び
		output(num,cut);
		//後処理
		scanner.close();
	}
	//出力
	public static void output(int num, int cut){
		StringBuilder sb = new StringBuilder("");
		sb.append(array[0]);
		for (int i = 1; i < num; i++) {
				if (i == cut) sb.append(" [" + array[i] + "]");
				else sb.append(" " + array[i]); 
		}
		System.out.println(sb);
	}
	//ソート
	public static int partition(int par,int rim){
		int work = 0;
		int x = array[rim];
		int i = par - 1;
		//ソート処理
		for (int j = par ; j < rim ; j ++ ){
			if ( array[j] <= x ) {
				work = array[++i];
				array[i] = array[j];
				array[j] = work;
			}
		}
		//最後に入れ替え
		work = array[++i];
		array[i] = array[rim];
		array[rim] = work;
		return i;
	}
}


Measured memory_bytes: 69252
#include <stdio.h>
#include <string.h>

int main()
{
	int len = 0, i = 0, c = 1, n, m;
	char s[100];
	scanf("%s", &s);
	len = strlen(s);

	for (i = 0; i < len; i++) {
		if (s[i] != s[len - 1 - i]) {
			c = 0;
			break;
		}
	}

	n = (len - 1) / 2;
	for (i = 0; i < n; i++) {
		if (s[i] != s[n - i - 1]) {
			c = 0;
			break;
		}
	}

	n = (len + 3) / 2;
	m = len - 1;
	for (i = n - 1; i < len; i++) {
		if (s[i] != s[m--]) {
			c = 0;
			break;
		}
	}

	if (c)
		printf("Yes");
	else
		printf("No");
	return 0;
}

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

struct Card { char suit; int value; };

void Selection_sort(struct Card A[], int N) {
    int tmp_minj, minj, j;
    for (int i=0; i<N; i++) {
        minj = i;
        tmp_minj = i;
        for (j=i; j<N; j++) {
            if (A[j].value < A[minj].value) { minj = j; }
        }
        if (tmp_minj != minj) { 
            swap(A[i].suit, A[minj].suit);
            swap(A[i].value, A[minj].value);
            }
    }
}

void BubbleSort(struct Card A[], int n) {
    int flag = 1;
    while (flag == 1) {
        flag = 0;
        for (int j=n-1; j>0; j--){
            if ( A[j].value < A[j-1].value ){
                swap(A[j].suit, A[j-1].suit);
                swap(A[j].value, A[j-1].value); 
                flag = 1;
            }
        }
    }
}

void Print(struct Card A[], int N) {
    for (int i=0; i<N; i++) {
        if (i > 0) { cout << " "; }
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool IsStable(struct Card C1[], struct Card C2[], int N) {
    for(int i = 0; i < N; i++) {
        if (C1[i].suit != C2[i].suit) { return false; }
    }
    return true;
}

int main(int argc, char const *argv[])
{
    Card C1[100], C2[100];
    int N;

    cin >> N;
    
    for(int i = 0; i < N; i++) {
        cin >> C1[i].suit >> C1[i].value;
        C2[i] = C1[i];
    }
    
    BubbleSort(C1, N);
    Selection_sort(C2, N);

    Print(C1, N);
    cout << "Stable" << endl;

    Print(C2, N);
    if( IsStable(C1, C2, N) ) {
        cout << "Stable" << endl;
    }
    else {
        cout << "Not stable" << endl;
    }

    return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

string SA;
string SB;
string SC;





int main()
{

	cin >> SA >> SB >> SC;
	int a = 0;
	int b = 0;
	int c = 0;


	char count = 'a';
	while(1){
		switch(count){
		case 'a':
			if(a == SA.length()){
				cout << 'A';
				return 0;
			}
			count = SA[a];
			a++;

			break;
		case 'b':
			if(b == SB.length()){
				cout << 'B';
				return 0;
			}
			count = SB[b];
			b++;

			break;
		case 'c':
			if(c == SC.length()){
				cout << 'C';
				return 0;
			}
			count = SC[c];
			c++;


			break;
		}

	}





}


Measured memory_bytes: 256
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a[2],b;
	
	while(cin>>a[0]>>a[1]>>b){
	
	bool used[11];	
	rep(i,11){
		used[i]=false;
	}
	used[a[0]]=true;
	used[a[1]]=true;
	used[b]=true;
	int many=0;
	for(int i=1;i<11;i++){
		if(used[i]){continue;}
		if(i+a[0]+a[1]<=20){many++;}
	}
	if(many>3){cout<<"YES"<<endl;}
	else{cout<<"NO"<<endl;}
	}
	return 0;
}


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

#define FOR(i,a,n) for (int i = a; i < n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = long long;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  int n; cin >> n;
  vector<int> a(n); REP(i,n) cin >> a[i];
  bool f = true, inc = false;
  int ans = 0;
  FOR(i,1,n) {
    if (a[i] == a[i-1]) continue;
    if (a[i] > a[i-1]) {
      if (f) { f = false, inc = true; continue;}
      if (inc) continue;
      f = true;
      ans++;
    } else {
      if (f) { f = false, inc = false; continue; }
      if (!inc) continue;
      f = true;
      ans++;
    }
  }
  cout << ans+1 << endl;
  return 0;
}


Measured memory_bytes: 640
ans = 0
def solve(balb, p, S, N, M):
    if len(S) == N:
        global ans

        up = 0
        for i in range(M):
            on = 0
            for j in balb[i]:
                if S[j] == "1":
                    on += 1

            if (on % 2 == p[i]):
                up += 1

        if up == M:
            ans += 1
        
    else:
        solve(balb, p, S + "1", N, M)
        solve(balb, p, S + "0", N, M)

def main():
    N, M = map(int, input().split())
    balb = list()

    for i in range(M):
        sw = [int(a) - 1 for a in input().split()]
        balb.append(sw[1:])

    p = [int(a) for a in input().split()]

    solve(balb, p, "", N, M)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9208
def read_friends():
    n, m = [int(x) for x in input().split()]
    adj_list = [set() for _ in range(n)]

    for _ in range(m):
        s, t = [int(x) for x in input().split()]
        adj_list[s].add(t)
        adj_list[t].add(s)

    return n, adj_list


def divide_group(n, adj_list):
    group = [None] * n

    def visit(k, g):
        S = [k]

        while S:
            k = S.pop()
            group[k] = g
            for t in adj_list[k]:
                if group[t] is None:
                    S.append(t)

    for k in range(n):
        if group[k] is None:
            visit(k, k)

    return group


def answer_queries(group):
    q = int(input())

    for _ in range(q):
        s, t = [int(x) for x in input().split()]
        print("yes" if group[s] == group[t] else "no")


def main():
    n, adj_list = read_friends()
    group = divide_group(n, adj_list)
    answer_queries(group)


if __name__ == '__main__':
    main()



Measured memory_bytes: 39320
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<utility>
#include<functional>
#include<iomanip>
#include<sstream>
#include<ctime>
#include<cassert>

//[a, b)
#define rep(i,a,b) for (int i=(a),_ed=(b);i<_ed;i++)
#define per(i,a,b) for (int i=(b)-1,_ed=(a);i>=_ed;i--)
#define vsort(v)   sort(v.begin(),v.end())
#define siz(x) ((int)(x).size())
#define ll long long
template <class T> inline T gcd(T a, T b) { if (b == 0)return a; return gcd(b, a%b); }

using namespace std;



int main() {
#ifdef debug 
	freopen("a.txt", "r", stdin);
#endif
	string  s;
	cin >> s;
	rep(i, 0, 4) {
		cout << s[i];
	}
	cout << " ";
	rep(i, 4, 12) {
		cout << s[i];
	}
	cout << endl;


	return 0;
}

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

int main(){
	int n;
	int count = 0;
	char parentheses;
	int parenthesesNum;

	cin >> n;
	for(int i=0; i < n; i++){
		cin >> parentheses >> parenthesesNum;

		if(parentheses == '(') count += parenthesesNum;
		else count -= parenthesesNum;

		if(count < 0){
			cout << "NO" << endl;
			return 0;
		}
	}
	if(count == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
using namespace std;
char s[1005];
int a123[1005][1005];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=1; i<=n; i++){
		scanf("%s",s);
		for (int j=0; j<m; j++)
			a123[i][j+1]=(s[j]=='#');
	}
	for (int i=1; i<=n; i++)
		for (int j=1; j<=m; j++)
			if (a123[i][j]){
				int flag=0;
				for (int k=0; k<4; k++){
					int fx=i+dx[k],fy=j+dy[k];
					if (i<1 || i>n || j<1 || j>m) continue;
					flag|=a123[fx][fy];
				}
				if (!flag) {
					printf("No\n");
					return 0;
				}
			}
	printf("Yes\n");
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<pair<pair<string,int>,int>> a;
  for(int i=1;i<=n;i++){
    string s;
    int p;
    cin>>s>>p;
    a.push_back(make_pair(make_pair(s,-1*p),i));
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    cout<<a.at(i).second<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
    cout << fixed << setprecision(10);
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int cnt = 0;
    for(int i = 0;i <= (n+r-1)/r; i++){
        for(int j = 0; j <= (n - i*r + g - 1)/g; j++){
            if( (n - i*r - j*g)%b == 0 && (n - i*r - j*g) >= 0) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int a, b, c, len;
int main(){
    scanf("%d %d",&a, &b);
    c = b;
    while(c > 0){
        c /= 10;
        len++;
    }
    a = a*pow(10,len)+b;
    if(sqrt(a) == floor(sqrt(a)))	
		printf("Yes\n");
    else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = [1]
c = 1
while(6**c <= 100000):
    l.append(6**c)
    c += 1
c = 1
while(9**c <= 100000):
    l.append(9**c)
    c += 1
l.sort()
dp = [100001 for _ in range(n+1)]
dp[0] = 0
for i in range(len(l)):
    for j in range(l[i],n+1):
        dp[j] = min(dp[j],dp[j - l[i]]+1)
print(dp[n])

Measured memory_bytes: 7064
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a != b && b != c && c != a || a == b && b == c && c == a){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

    long a,b;
    scanf("%ld %ld",&a,&b);

    long sum=a+b;
    sum=sum/2;

    long left=a-sum;
    long right=b-sum;
    if(left<0)left=-left;
    if(right<0)right=-right;

    if(left==right){
        printf("%ld\n",sum);
    }else{
        printf("IMPOSSIBLE\n");
    }
    return 0;
}

Measured memory_bytes: 128
#pragma gcc optimize (o3)
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define ll long long
#define ld long double
#define U unsigned
#define pi acos(-1)

using namespace std;

const ll N = 1e5+5;

ll dp[N][4], a[N][3], n;

ll solveI()
{
    for(int i = n ; i > 0 ; i--)
    {
        for(int j = 0 ; j < 4 ; j++)
        {
            for(int k = 0 ; k < 3 ; k++)
            {
                if(j != k) dp[i][j] = max(dp[i][j], dp[i+1][k] + a[i][k]);
            }
        }
    }
    return dp[1][3];
}

int main()
{
    scanf("%lld", &n);
    for(int i = 1 ; i <= n ; i ++) scanf("%lld%lld%lld", &a[i][0], &a[i][1], &a[i][2]);
    printf("%lld", solveI());
    return 0;
}


Measured memory_bytes: 5760
import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        sc.close();

        int[] input_ary = new int[4];
        for (int i = 0; i < 4; i++) {
            input_ary[i] = input.charAt(i) - '0';
        }

        String[] calc_ary = new String[8];
        int cnt = 0;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                for (int k = 0; k < 2; k++) {
                    sb.append(i);
                    sb.append(j);
                    sb.append(k);
                    calc_ary[cnt] = sb.toString();
                    sb = new StringBuilder();
                    cnt++;
                }
            }
        }

        char target = 0;
        int sum = 0;
        for (String elm : calc_ary) {
            sum = input_ary[0];
            for (int i = 0; i < elm.length(); i++) {
                target = elm.charAt(i);
                switch (target) {
                case '0':
                    sum -= input_ary[i + 1];
                    break;
                case '1':
                    sum += input_ary[i + 1];
                    break;
                }
            }
            if (sum == 7) {
                sb.append(input_ary[0]);
                sb.append(elm.charAt(0) == '0' ? "-" : "+");
                sb.append(input_ary[1]);
                sb.append(elm.charAt(1) == '0' ? "-" : "+");
                sb.append(input_ary[2]);
                sb.append(elm.charAt(2) == '0' ? "-" : "+");
                sb.append(input_ary[3]);
                sb.append("=7");
                break;
            }
            sum = 0;
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 22612
package main

import (
	"fmt"
)

func main() {
	var n, x, t int64
	fmt.Scan(&n, &x, &t)

	if n % x == 0 {
		fmt.Println(n/x * t)
	} else {
		fmt.Println((n/x + 1) * t)
	}
}


Measured memory_bytes: 1772
if __name__ == "__main__":
    N = int(input())
    a = list(map(int, input().split()))
    n1 = 0
    n2 = 0
    n4 = 0
    for i in a:
        if i % 4 == 0:
            n4 += 1
        elif i % 2 == 0:
            n2 += 1
        else:
            n1 += 1
    if n2 == 0 and n4 == 0 and n1 == 1:
        print("Yes")
    else:
        if n1 <= n4:
            print("Yes")
        elif n1 == n4 + 1:
            if n2 == 0:
                print("Yes")
            else:
                print("No")
        else:
            print("No")


Measured memory_bytes: 14252
#include<stdio.h>
int main()
{
int N,K,X,Y,T;
scanf("%d",&N);
scanf("%d",&K);
scanf("%d",&X);
scanf("%d",&Y);
if(K>=N){T=N*X;}  
else{T=K*X+(N-K)*Y;}
printf("%d",T);  
 return 0;
}

Measured memory_bytes: 256
n = int(input())
ls_a = list(map(int,input().split()))
cnt = 1
ans = 0
check = 0
for i in ls_a:
    if i == cnt:
        cnt+=1
    else:
        ans += 1
    if i == 1:
        check = 1
# print(cnt)
if check == 1:
    print(ans)
else:
    print(-1)

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

#define int long long
#define w cout
#define e '\n'
#define sz(x) (int)x.size()
template<class T, class U> inline istream& operator>>(istream& str, pair<T, U> &p) { return str >> p.first >> p.second; }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

const int N = 1e6 + 10 , mod = 1e9 + 7;

int arr[N];

signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n; cin >> n;
	int a , b; cin >> a >> b;
	if(a > b) swap(a , b);
	if((a % 2) == (b % 2)) {
		w << (b - a) / 2 ;
		return 0;
	}
	int ans1 = (b - a) / 2;
	ans1 += a;
	int ans2 = (b - a) / 2;
	ans2 += n - b + 1; 
	w << min(ans1 , ans2);
}
	
		
        


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x


using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
const long long MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

int main() {
    int n,m;cin>>n>>m;
    vector<int> cnt(n,1);
    vector<int> flag(n,0);
    flag[0]=1;
    
    rep(i,m){
        int a,b;cin>>a>>b;
        a--;b--;
        
        cnt[a]--;
        cnt[b]++;
        if(flag[a]==1){
            flag[b]=1;
        }
        
        if(cnt[a]==0)flag[a]=0;
        

        
        
    }
    
    int c=0;
    rep(i,n){
        c+=(flag[i]==1);
    }
    
    cout<<c<<endl;
    
    return 0;
}





Measured memory_bytes: 1024
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, C float64
	fmt.Scan(&a, &b, &C)
	S := 1.0 / 2.0 * a * b * math.Sin(math.Pi*C/180.0)
	L := a + b + math.Sqrt(a*a+b*b-2.0*a*b*math.Cos(math.Pi*C/180.0))
	h := 2.0 * S / a
	fmt.Printf("%f\n", S)
	fmt.Printf("%f\n", L)
	fmt.Printf("%f\n", h)
}



Measured memory_bytes: 1176
#include <stdio.h>

int main(){
  int d;
  scanf("%d",&d);
  if (d == 25) {
    printf("Christmas\n");
  }
  else if (d == 24) {
    printf("Christmas Eve\n");
  }
  else if (d == 23) {
    printf("Christmas Eve Eve\n");
  }
  else if (d == 22) {
    printf("Christmas Eve Eve Eve\n");
  }
}


Measured memory_bytes: 128
//9.8 AT2141
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string q;
	cin>>q;
	int m[100001]={0};
	int a=0,sum=0;
	for(int i=0;i<q.size();i++) 
	{
		if(q[i]=='p') m[i]=1;
		else m[i]=0;
	}
	for(int i=0;i<q.size();i++)
	{
		if(i%2==0) a=0;
		else a=1;
		if(a>m[i]) sum++;
		else if(a<m[i]) sum--;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 896
eval'N,K,*A='+`dd`.split*?,
A.sort!
b=s=K%2<1?1:A.pop
i=0
(K/2).times{x=A[i]*A[i+1]
s*=x*b>b*A[-1]*A[-2]?(i+=2
x):A.pop*A.pop
s%=10**9+7}
p s

Measured memory_bytes: 54692
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) a.begin(), a.end()
typedef long long int ll;
using namespace std;

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

    int a, b, k;
    cin >> k >> a >> b;

    ll have     = 1;
    bool change = false;

    if (a + 1 >= b) {
        cout << have + k << endl;
        return 0;
    }

    for (int i = 0; i < k; i++) {
        if (i == k - 1 && change == false) {
            have++;
            break;
        }
        if (change) {
            change = false;
            have += b;
        } else if (have >= a) {
            change = true;
            have -= a;
        } else {
            have++;
        }
    }

    cout << have << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)

# Override `input` function because `stdin.readline()` is 10x faster than built-in `input()`
input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    S, = read_h(typ=str)
    n = len(S) - 1

    total = 0
    for i in range(2**n):
        prev = 0
        for j in range(n):
            #  print(i, j)
            if ((i >> j) & 1):
                #  print(i, j)
                m = int(S[prev:j + 1])
                #  print(m)
                total += m
                prev = j + 1

        m = int(S[prev:])
        #  print(m)
        total += m

    print(total)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39280
#include <iostream>
using namespace std;
int main()
{
	int n,total=0,x=15;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		total+=800;
		if(i%x==0)
		{
			total-=200;
			x+=15;
		}
	}
	cout<<total;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;

    vector<vector<bool>> graph(N, vector<bool>(N, false));
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a][b] = true;
        graph[b][a] = true;
    }
    vector<vector<ll>> dp(1 << N, vector<ll>(N, 0));
    dp[1][0] = 1;
    rep(s, 1 << N) {
        rep(to, N) {
            if ((s & (1 << to)) == 0) continue;
            ll s2 = s ^ (1 << to);
            rep(from, N) {
                if ((s2 & (1 << from)) && graph[from][to]) dp[s][to] += dp[s2][from];
            }
        }
    }
    ll ans = 0;
    rep2(i, 1, N) {
        ans += dp[(1 << N) - 1][i];
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main() {

  int c = 4280;
  int a[3] = {125,140,160};
  int b = 1150;
  while(1) {

    int n;
    cin >> n;
    if(n == -1) break;

    b = 1150;
    if(n >=10 )n -= 10;
    else n = 0;
    int i =0;
    while(n >= 10){
      if(i == 3) i--;
      b += a[i]*10;
      n -= 10;
      i++;
      //    cout <<i<<" "<<n <<" "<< b<< endl;
     
    }
    // cout <<i << endl;
    if(i==3)i--;
    for(int j=0;j<n;j++) b +=a[i];
      
    cout << c - b << endl;
    
  }

  return 0;

}

Measured memory_bytes: 1160