akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int sa[100005], sb[100005];
char a[100005], b[100005];

int main() {
	scanf("%s%s", a, b);
	int na = strlen(a);
	int nb = strlen(b);
	REP(i, na)sa[i + 1] = sa[i] + (a[i] == 'B');
	REP(i, nb)sb[i + 1] = sb[i] + (b[i] == 'B');
	int Q;
	scanf("%d", &Q);
	REP(q, Q) {
		int x, y, z, w;
		scanf("%d%d%d%d", &x, &y, &z, &w);
		if ((y - x +1 + sa[y] - sa[x - 1]) % 3 == (w - z +1+ sb[w] - sb[z - 1]) % 3) printf("YES\n");
		else printf("NO\n");
	}

	return 0;
}

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

manzoku = 0
maenoosara = a[0]

for i in range(n):
  tabeteruosara = a[i]
  manzoku = manzoku + b[tabeteruosara - 1]

  if tabeteruosara - maenoosara == 1:
      manzoku = manzoku + c[tabeteruosara - 2]

  maenoosara = tabeteruosara

print(manzoku)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef bitset<35> sta;
int n,a[200005],b[200005];
int main(){
	cin>>n;
	for (int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	for (int i=n;i>=1;--i){
		if (i*2>n) b[i]=a[i];
		else{
			int sum=0;
			for (int j=i+i;j<=n;j+=i)sum=(sum+b[j])%2;
			b[i]=sum^a[i];
		}
	}
	int tot=0;
	for (int i=1;i<=n;++i) tot+=b[i];
	cout<<tot<<endl;
	for (int i=1;i<=n;++i)
		if (b[i]) printf("%d ",i);
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;

int main(){
  int n,k;
  cin>>n>>k;
  k=min(k,50);
  int a[n],b[n];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int j=0;j<k;j++){
    for(int i=0;i<n;i++)b[i]=0;
    for(int i=0;i<n;i++){
      b[max(0,i-a[i])]++;
      if(min(n-1,i+a[i])+1<n)b[min(n-1,i+a[i])+1]--;
    }
    for(int i=1;i<n;i++)b[i]+=b[i-1];
    for(int i=0;i<n;i++)a[i]=b[i];
  }
  for(int i=0;i<n;i++)cout<<a[i]<<endl;
}


Measured memory_bytes: 5180
N=int(input())
A=list(map(int, input().split()))
#和の符号が異なる


ans1=0
ans2=0

if A[0]==0:
    a0_1=1
    a0_2=-1
    ans1+=1
    ans2+=1
elif A[0]>1:
    a0_1=A[0]
    a0_2=-1
    ans2+=A[0]+1
else:
    a0_1=1
    a0_2=A[0]
    ans1+=1-A[0]


now1=a0_1
for i in range(1,N):
    if now1*(now1+A[i])<0:
        now1+=A[i]
    else:
        if now1>0:
            add=(-1)*(now1+1)
        else:
            add=(-1)*(now1-1)
        now1+=add
        ans1+=abs(add-A[i])
    #print(now1)

now2=a0_2
for i in range(1,N):
    if now2*(now2+A[i])<0:
        now2+=A[i]
    else:
        if now2>0:
            add=(-1)*(now2+1)
        else:
            add=(-1)*(now2-1)
        now2+=add
        ans2+=abs(add-A[i])
ans=min(ans1, ans2)
print(ans)
#print(ans1, ans2)

Measured memory_bytes: 14468
#include<stdio.h>
#include<string.h>
int main(){
	int n;
	double ans=0;
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++){
		double x;
		char u[5];
		scanf("%lf %s",&x,u);
		if(strcmp(u,"JPY")==0)
			ans += x;
		else
			ans +=x*380000;
	}
	printf("%lf\n",ans);
	return 0;
}
			
			

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var n, k, q int
	fmt.Scan(&n, &k, &q)

	list := make([]int, q)
	for i := 0; i < q; i++ {
		fmt.Scan(&list[i])
	}

	scoreList := make([]int, n)
	for i := 0; i < n; i++ {
		scoreList[i] = k - q
	}

	for i := 0; i < q; i++ {
		scoreList[list[i]-1]++
	}
	for i := 0; i < n; i++ {
		if scoreList[i] > 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 5888
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt(), A = sc.nextInt(), B = sc.nextInt();
		int[] prob = new int[3];
		for(int i = 0; i < N; i++) {
			int P = sc.nextInt();
			if(P <= A) prob[0]++;
			else if(P > B) prob[2]++;
			else prob[1]++;
		}
		System.out.println(Math.min(prob[0], Math.min(prob[1], prob[2])));
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;

bool isPrime(int x){
	int d=5;
	for(int i=6;i<x;i+=d){
		d=7-d;
		if(x%i==0){
			return false;
		}
	}
	return true;
}

int main(){
	int N;
	while(cin>>N&&N!=1){
		int d=5;
		cout<<N<<":";
		for(int i=6;i<=N;i+=d){
			d=7-d;
			if(N%i==0){
				if(isPrime(i))	cout<<" "<<i;
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 2976
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 3000;
int BIG = 1e+18+3;
int mod = 1e+9+7;

int memoized[3000][3000];
string s,t; 
string ans;

int dp(int x, int y)
{

    if (x==-1 || y==-1)
        return 0;

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

    if (s[x]==t[y])
        memoized[x][y] = 1+dp(x-1,y-1);

        
    else
        memoized[x][y] = max(dp(x-1,y),dp(x,y-1));

    return memoized[x][y];
}

void track(int x, int y)
{
    if (x==-1 || y==-1)
        return ;

    if (s[x]==t[y])
    {
        ans+=s[x];
        track(x-1,y-1);
    }

    else
        if (dp(x-1,y)>dp(x,y-1))
            track(x-1,y);
        else
            track(x,y-1);

}

signed main()
{
    IOS;
    
    cin>>s>>t;

    int n = s.length();
    int m = t.length();
    n--;
    m--;

    repa(i,0,2999)
        repa(j,0,2999)
            memoized[i][j] = -1;

    int buffer = dp(n,m);

    track(n,m);

    reverse(ans.begin(),ans.end());

    cout<< ans <<endl;
}

Measured memory_bytes: 70784
h,w=map(int,input().split())
s=["*"*(w+2)]
for i in range(h):
  s.append("*"+input()+"*")
s+=["*"*(w+2)]
a=[[0]*w for _ in range(h)]
for i in range(h):
  for j in range(w):
    if s[i+1][j+1]=="#":
      a[i][j]="#"
    else:
      a[i][j]=(s[i][j:j+3]+s[i+1][j:j+3]+s[i+2][j:j+3]).count("#")
for i in a:
  print("".join(map(str,i)))

Measured memory_bytes: 3188
n = int(input())
A = list(map(int,input().split()))

A_max = max(A)
L = [0]*(A_max+1)
A.sort()

for a in A:
    temp = a
    while temp < A_max+1:
        L[temp] += 1
        temp += a

ans = 0
for a in A:
    if L[a] == 1:
        ans += 1

print(ans)


Measured memory_bytes: 32384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int INF = 2e9;
#define pb push_back
#define mp make_pair
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 (a>b) { a=b; return 1; } return 0; }

int main(){
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if(n==1 && m==1){
        ans = 1;
    }
    else if(n==1){
        ans = m - 2;
    }
    else if(m==1){
        ans = n - 2;
    }
    else{
        ans = (n-2)*(m-2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    static long[] last = new long[26];
    static long[] c = new long[26];
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        long[][] s = new long[d+1][26];

        for(int i=0; i<26; i++) {
            c[i] = sc.nextLong();
        }

        for(int i=1; i<=d; i++) {
            for(int j=0; j<26; j++) {
                s[i][j] = sc.nextLong();
            }
        }

        for(int i=1; i<=d; i++) {
            System.out.print(1);
            if(i!=d) {
                System.out.print("\n");
            }
        }
    }
}

Measured memory_bytes: 46560
require "prime"

N = gets.to_i
MOD = 10**9 + 7

hash = {}
hash.default = 1

(2..N).map{|i|
  i.prime_division.each{|a, b|
    hash[a] += b
  }
}

p (hash.each_value.inject(:*) || 1) % MOD


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

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

    if (n < 3) {
        cout << 1 << endl;
        return 0;
    }

    int c = 1;
    int a;
    int p;
    cin >> p >> a;
    int pinc = a - p;
    int inc;
    for (int i = 2; i < n; i++) {
        p = a;
        cin >> a;
        inc = a - p;
        if (pinc < 0 && inc > 0 || pinc > 0 &&  inc < 0) {
            c++;
            pinc = 0;
        } else {
            if (inc != 0) {
                pinc = inc;
            }
        }
    }

    cout << c << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{   int s=0,i,j,n;
	scanf("%d",&n);
	 int a[n];
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	for(i=0;i<n-1;i++)
	for(j=i+1;j<n;j++)
	{
		s=s+a[i]*a[j];
	}
	printf("%d\n",s);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class K, class V>
class RadixHeap {
    static constexpr int bit_length = sizeof(K)*8;
    K last;
    size_t sz, cnt;

    array<vector<pair<K, V>>, bit_length> v;
    static inline int bsr(int x){
        return x ? bit_length-__builtin_clz(x) : 0;
    }
    static inline int bsr(ll x){
        return x ? bit_length-__builtin_clzll(x) : 0;
    }

    void pull() {
        if(cnt < v[0].size()) return;;
        int i = 1;
        while(v[i].empty()) i++;
        last = min_element(v[i].begin(),v[i].end())->first;
        for (auto &&x : v[i]) v[bsr(x.first ^ last)].push_back(x);
        v[i].clear();
    }
public:
    RadixHeap() : last(0), sz(0), cnt(0) {}
    void emplace(K x, V val){
        sz++;
        v[bsr(x^last)].emplace_back(x, val);
    }

    pair<K, V> top() {
        pull();
        return v[0][cnt];
    }

    void pop() {
        pull();
        sz--;
        cnt++;
    }

    size_t size() const { return sz; }
    bool empty() const { return !sz; }
};

template <typename T>
struct edge {
    int from, to;
    T cost;

    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

    explicit operator int() const {return to;}
};

template <typename T>
vector<T> dijkstra(int s,vector<vector<edge<T>> > &G){
    int n=G.size();
    const T INF = numeric_limits<T>::max();
    using P = pair<T, int>;
    vector<T> d(n, INF);
    vector<int> b(n,-1);
    RadixHeap<T, int> Q;
    d[s]=0;
    Q.emplace(d[s],s);
    while(!Q.empty()){
        T cost;
        int i;
        tie(cost, i) = Q.top(); Q.pop();
        if(d[i] < cost) continue;
        for (auto &&e : G[i]) {
            auto cost2 = cost + e.cost;
            if(d[e.to] <= cost2) continue;
            d[e.to] = cost2;
            Q.emplace(d[e.to], e.to);
        }
    }
    return d;
}

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    vector<vector<edge<ll>>> vy(n), vs(n);
    for (int i = 0; i < m; ++i) {
        ll u, v, a, b;
        scanf("%lld %lld %lld %lld", &u, &v, &a, &b);
        vy[u-1].emplace_back(v-1, a);
        vy[v-1].emplace_back(u-1, a);
        vs[u-1].emplace_back(v-1, b);
        vs[v-1].emplace_back(u-1, b);
    }
    vector<ll> cy = dijkstra(s-1, vy), cs = dijkstra(t-1, vs);
    for (int i = 0; i < n; ++i) {
        cy[i] += cs[i];
    }
    for (int i = n-2; i >= 0; --i) {
        cy[i] = min(cy[i], cy[i+1]);
    }
    for (int i = 0; i < n; ++i) {
        printf("%lld\n", 1000000000000000-cy[i]);
    }
    return 0;
}


Measured memory_bytes: 22304
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  char cur;
  long long ans=0;
  for(int i=0;i<s.length();i++)
  {
    if(i==0)cur=s[i];
    else if(s[i]!=cur)
    {
      cur=s[i];
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 512
// ABC122_D
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    string S;
    cin >> S;
    
    // calculation
    if (S == "A") {
        cout << "T" << "\n";
    } else if (S == "T") {
        cout << "A" << "\n";
    } else if (S == "G") {
        cout << "C" << "\n";
    } else if (S == "C") {
        cout << "G" << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
def numchange(boo):
    if boo:return 1
    else: return -1

while True:
    m,n = map(int,input().split())
    if m==0: break

    yaxis = 1
    xaxis = 1
    rotation = 0
    while True:
        lnr = input()
        if lnr == "STOP": break
        elif lnr == "RIGHT": rotation = (rotation+1)%4
        elif lnr == "LEFT": rotation = (rotation+3)%4
        else:
            movequeue = lnr.split()
            moveamount = int(movequeue[1]) * numchange((rotation//2)==0) * numchange(movequeue[0]=="FORWARD")
            if rotation%2==0:
                yaxis += moveamount
                if yaxis <= 0:
                    yaxis = 1
                elif yaxis > n:
                    yaxis = n
            else:
                xaxis += moveamount
                if xaxis <= 0:
                    xaxis = 1
                elif xaxis > m:
                    xaxis = m
    print(xaxis,yaxis)

Measured memory_bytes: 7640
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int A,B,C;
  cin >> A >> B >> C;
  if(A%2 == 1 && B%2 == 1 && C%2 == 1){
    cout << min({A*B,B*C,C*A}) << endl;
  }else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
using ll = long long;
int a[100005], b[100005], mx = -1e9, sec, pos, ans;
int main()
{
	// freopen("ARC103-C.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		int x;
		scanf("%d", &x);
		(i & 1 ? a : b)[x]++;
	}
	for (int i = 1; i <= 1e5; i++)
	{
		if (a[i] > mx)
		{
			sec = mx;
			mx = a[i];
			pos = i;
		}
		else
			sec = std::max(sec, a[i]);
	}
	for (int i = 1; i <= 1e5; i++)
		ans = std::max(ans, b[i] + (i == pos ? sec : mx));
	printf("%d\n", n - ans);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;
int main() {
    int a;
    cin >> a;
    int count = 0, sum = 0, longest = 0;
    while(count < a){
        count++;
        int L;
        cin >> L;
        sum += L;
        if(longest < L) longest = L;
    }
    sum -= longest;
    if(sum > longest)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

class vector2d
{
public:
	vector2d(float vx, float vy) : x(vx), y(vy)
	{}
	void normalize()
	{
		float n = sqrt(x*x + y*y);
		x /= n;
		y /= n;	
	}
public:
	float x,y;
};

float dot(vector2d& v1, vector2d& v2)
{
	return v1.x*v2.x + v1.y*v2.y;
}

float cross(vector2d& v1, vector2d& v2)
{
	return v1.x*v2.y - v2.x*v1.y;
}

int main(int argc, char const *argv[])
{
	float x1, y1, x2, y2, x3, y3, xp, yp;
	while(scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF)
	{
		float miny = (y1 < y2) ? y1 : y2;
		miny = (miny < y3) ? miny : y3;
		if (miny == y2)
		{
			swap(x2, x1);
			swap(y2, y1);
		}
		else if (miny == y3)
		{
			swap(x3, x1);
			swap(y3, y1);
		}
		vector2d v1(x2-x1,y2-y1); v1.normalize();
		vector2d v2(x3-x1,y3-y1); v2.normalize();
		vector2d ve(1.0,0.0);
		bool ans = true;
		vector2d vp1(xp-x1,yp-y1);
		vector2d vp2(xp-x2,yp-y2);
		vector2d vp3(xp-x3,yp-y3);
		if (dot(ve,v1) < dot(ve,v2))
		{
			vector2d v2(x3-x2,y3-y2);
			vector2d v3(x1-x3,y1-y3);
			ans &= cross(v1, vp1) < 0;
			ans &= cross(v2, vp2) < 0;
			ans &= cross(v3, vp3) < 0;
		}
		else
		{
			vector2d v1(x3-x1,y3-y1);
			vector2d v2(x1-x2,y1-y2);
			vector2d v3(x2-x3,y2-y3);
			ans &= cross(v1, vp1) < 0;
			ans &= cross(v2, vp2) < 0;
			ans &= cross(v3, vp3) < 0;
		}
		if (ans)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll pw(ll a, ll b) {
    if (b == 0) return 1;
    ll t = pw(a, b / 2);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
int main()
{
	int t;cin>>t;
	// t=1;
	int a=0,w=0,tl=0,r=0;
	while(t--)
	{
		string s;cin>>s;
		if(s[0]=='A')a++;
		else if(s[0]=='W')w++;
		else if(s[0]=='T')tl++;
		else r++;
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<w<<endl;
	cout<<"TLE x "<<tl<<endl;
	cout<<"RE x "<<r<<endl;
}


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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;


//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#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;

#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


struct Edge {
    int to, from;
    ll cost;
    Edge(int from, int to, ll cost): from(from), to(to), cost(cost) {}
};

typedef vector<vector<Edge>> AdjList;
AdjList graph;

int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    vector<int> v;

    int K,X; cin >> K >> X;

    for(int i=X-K+1; i<=X+K-1; ++i){
        if(i!=X-K+1) cout << " ";
        cout << i;
    }
    cout << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
string s;
int a[300010];
int main(){
  int n;
  while(cin>>n){
   	cin>>s;
    int cnt=0, ans=n;
	for(int i=0; i<n; ++i){
      a[i]=cnt;
    	if(s[i]=='W')
          ++cnt;
    }
      cnt=0;
	for(int i=n-1; i>=0; --i){
    	a[i]+=cnt;
      if(s[i]=='E')
          ++cnt;
    }
      for(int i=0; i<n; ++i)
        ans=min(ans, a[i]);
       cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    long long l[n];
    l[0]=2; l[1]=1;
    for (i=2;i<=n;i++)
    l[i]=l[i-1]+l[i-2];
    cout<<l[n]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	set<int> se;
	rep(i, 3){
		int d; cin >> d;
		se.insert(d);
	}
	cout << se.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main(){
	int n;
	scanf("%d",&n);
	int sum=0;
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		sum+=a[i];
	}
	int m=10005;
	for(int i=0;i<n;i++)
		m=min(abs(sum-a[i]*n),m);
	for(int i=0;i<n;i++){
		if(abs(sum-a[i]*n)==m){
			printf("%d",i);
			return 0;
		}
	} 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int A, B;
  cin >> A >> B;
  cout << max(A - 2 * B, 0) << endl;
  return 0;
}



Measured memory_bytes: 256
def Antennas(a,b,c,d,e,k):
    if (b-a)>k or (c-a)>k or (d-a)>k or (e-a)>k:
        return ':('
    else:
        return 'Yay!'

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
print(Antennas(a,b,c,d,e,k))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(a,b,c) for(int a=(b);a<=(c);++a)
const int mod=1e9+7,maxn=1e5+5;
int a[maxn],d[maxn],ci[maxn],vis[maxn],fl[maxn],sum[maxn],f[maxn];
int add(int a,int b){a+=b;return a>=mod?a-mod:a;}
int n,ans=1;
#define GG exit((puts("0"),0))
void solve(int x)//基环树 
{
	int cur,ths,lst,fst;
	cur=ths=lst=fst=0;
	while(ci[x])
	{
		++cur,ci[x]=0;
		if(fl[x])
		{
			if(ths==0)ths=lst=cur,fst=fl[x];
			else
			{
				if(fl[x]>cur-lst)GG;
				if(fl[x]==cur-lst)ans=ans;
				if(fl[x]<cur-lst)ans=add(ans,ans);
				lst=cur;
			}
		}
		x=a[x];
	} 
	if(!ths)sum[cur]++;
	else
	{
		if(fst>cur-lst+ths)GG;
		if(fst==cur-lst+ths)ans=ans;
		if(fst<cur-lst+ths)ans=add(ans,ans);
	}
}
main()
{
	scanf("%d",&n);
	f(i,1,n)scanf("%d",a+i),d[a[i]]++;
	int x,l;
	f(i,1,n)
	{
		if(!vis[i])
		{
			for(x=i;!vis[x];vis[x]=i,x=a[x]);
			if(vis[x]!=i)continue;
			while(!ci[x])ci[x]=1,x=a[x];
		}
	}
	f(i,1,n){
		if(ci[i]&&d[i]>=3)GG;
		if(!ci[i]&&d[i]>=2)GG;
	}
	f(i,1,n)
	{
		if(d[i])continue;
		for(x=i,l=0;!ci[x];x=a[x],l++);
		fl[x]=l;
	}
    f(i,1,n)if(ci[i])solve(i);//基环树
    f(i,1,n)//简单环
	{
		f[0]=1;
		f(j,1,sum[i])
		{
			if(i>1&&i%2==1)f[j]=add(f[j-1],f[j-1]);
			else f[j]=f[j-1];
			if(j>1)f[j]=add(f[j],(ll)f[j-2]*(j-1)%mod*i%mod);
		}
		ans=(ll)ans*f[sum[i]]%mod;
	} 
	printf("%d",ans); 
 } 

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

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

	std::vector< std::vector<int> > v;
	for(int i = 0; i < m; ++i){
		int a, b;
		std::cin >> a >> b;
		std::vector<int> temp;
		temp.push_back(a - 1);
		temp.push_back(b - 1);
		v.push_back(temp);
	}

	std::vector<int> res(n, 0);
	for(int j = 0; j < n; ++j){
		for(unsigned int k = 0; k < v.size(); ++k){
			if(v.at(k).at(0) == j || v.at(k).at(1) == j)++res.at(j);
		}
	}

	for(int j = 0; j < n; ++j){
		std::cout << res.at(j) << std::endl;
	}

	return 0;
}


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

int main() {
    int n;
    cin >> n;
    deque<ll> d;
    rep(i, n) {
        ll a;
        cin >> a;
        int idx = lower_bound(d.begin(), d.end(), a) - d.begin() - 1;
        if (idx < 0) {
            d.push_front(a);
        }
        else {
            d[idx] = a;
        }
    }
    cout << d.size() << endl;
    return 0;
}


Measured memory_bytes: 4360
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

s = ni()
max_n = s//3
ans = 0
mod = 10**9+7

for n in range(1,max_n+1):
  ss = s-3*n
  ans += cmb(ss+n-1,n-1,mod)
  ans %= mod

print(ans%mod)

Measured memory_bytes: 86736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef unsigned long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
constexpr int mod = 1e9+7;

int main() {
  int k;
  cin >> k;
  ll cur = 7;
  int res = -1;
  for ( int i = 1; i <= 2000000; i++) {
    if (cur % k == 0) {
      res = i;
      break;
    }
    (cur *= 10) %= k;
    (cur += 7) %= k;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main() {
  int A,B;
  cin >> A >> B;
  int i;
  for(i=0;i<10000;i++) {
    if((int)((double)i*0.08)/1==A && (int)((double)i*0.1)/1==B) {
      cout << i << endl;
      i = 10001;
    }
  }
  if(i == 10000)cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, X, Y;
	cin >> N >> X >> Y;
	--X;
	--Y;
	vector<vector<int>> G(N);
	for (auto i = 0; i < N - 1; ++i)
	{
		G[i].push_back(i + 1);
		G[i + 1].push_back(i);
	}
	G[X].push_back(Y);
	G[Y].push_back(X);

	vector<int> ans(N);
	for (auto i = 0; i < N; ++i)
	{
		vector<int> d(N, INT_MAX);
		d[i] = 0;
		queue<int> q;
		q.push(i);
		while (!q.empty())
		{
			auto u = q.front();
			q.pop();
			for (auto v : G[u])
			{
				if (d[v] < INT_MAX)
				{
					continue;
				}

				d[v] = d[u] + 1;
				q.push(v);
				if (i < v)
				{
					++ans[d[v]];
				}
			}
		}
	}

	for (auto i = 1; i < N; ++i)
	{
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 384
# coding:utf-8
from pprint import pprint


def bellman_ford(V, E, s):
    """ 始点sから残りのノードへの最短経路を求めるベルマンフォード法
    :param V: 頂点数
    :param E: (ノード1, ノード2, コスト)のタプルのリスト
    :param s: 始点とするノード
    :return : (距離リスト, 最短経路, 負の辺によるループが存在するか)a
    """
    ##### 前処理 #####
    from collections import defaultdict
    # INFの定義
    INF = 2**63 - 1
    # 最短経路情報を格納する辞書
    dist = defaultdict(lambda: INF) # 始点から始点への移動コスト
    dist[s] = 0
    # 移動経路の履歴
    pre = {}

    ##### 最短経路算出 #####
    # 高々|V|-1回の探索でいい(|V|回以上更新がある場合は負の閉路が存在)
    for i in range(V-1):
        for n1, n2, w in E:
            # 始点からi回の探索でたどり着けない頂点は考慮しない
            # 始点 -> n2 までの最短距離 > 始点 -> n1 までの最短距離 + n1 -> n2 への移動コスト
            # の場合より短い経路が発見できたと言うことなので情報を更新
            if dist[n1] != INF and dist[n2] > dist[n1] + w:
                dist[n2] = dist[n1] + w
                pre[n2] = n1

    ##### 負の閉路検出 #####
    is_cycle = False
    cycle_node = []
    for n1, n2, w in E:
        # 正しい最短距離が求まったと仮定(重要)
        # 始点 -> n1 までの最短距離 + n1 -> n2 への移動コスト < 始点 -> n2 までの最短経路
        if dist[n1] + w < dist[n2]:
            is_cycle = True
            cycle_node.append(n1)

    ##### Infか判定 #####
    is_inf = False
    if is_cycle:
        route_node = V
        while route_node != s:
            route_node = pre[route_node]
            if route_node in cycle_node:
                is_inf = True
                break

    return 'inf' if is_inf else str(-dist[V])


def main():
    # 頂点，辺の数
    N, M = map(int, input().split(' '))
    # 辺の情報
    E = []
    for _ in range(M):
        a, b, c = map(int, input().split(' '))
        E.append((a, b, -c))

    print(bellman_ford(N, E, 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if(S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

int dsum(long long n) {
  int res = 0;
  while (n > 0) {
    res += n % 10;
    n /= 10;
  }
  return res;
}

int main() {
  long long K;
  cin >> K;
  long long x = 1;
  long long p = 1;
  while (K > 0) {
    cout << x << endl;
    K--;
    if (K < 0) break;
    long long nx1 = x + p;
    long long nx2 = x + p * 10;
    if (nx1 * dsum(nx2) <= nx2 * dsum(nx1)) {
      x = nx1;
    } else {
      x = nx2;
      p *= 10;
    }
  }
}


Measured memory_bytes: 256
from collections import deque


def order_manegement():
    while True:
        yield 1
        yield 0


def main():
    s = input()
    q = int(input())
    s = deque(s)
    gen = order_manegement()
    state = 0
    for i in range(q):
        order = list(input().split())
        if order[0] == '1':
            state = next(gen)
        elif order[0] == '2':
            if (state + int(order[1])) % 2 == 0:
                s.append(order[2])
            else:
                s.appendleft(order[2])
    s = list(s)
    if state == 1:
        s = s[::-1]

    print(''.join(s))


if __name__ == '__main__':
    main()


Measured memory_bytes: 13896
using System;

namespace _9_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int kaisuu=int.Parse(Console.ReadLine());
            int taro = 0;
            int hanako = 0;
            for(int i=0;i<kaisuu;i++)
            {
                string[] x = Console.ReadLine().Split();
                string Taro = x[0];
                string Hanako = x[1];
                Array.Sort(x);
                if(Taro==Hanako)
                {
                    taro++;
                    hanako++;
                }
                else if(x[1]==Taro)
                {
                    taro += 3;
                }
                else
                {
                    hanako += 3;
                }
            }
            Console.WriteLine(taro + " " + hanako);
        }
    }
}

Measured memory_bytes: 9916
#include <bits/stdc++.h>
using namespace std;
int A, B, C, X, Y;

//1秒間に処理できるfor文の回数は概ね10^8回程度
//atcoderでは2秒以内に実行を完了する必要がある
//この問題だとfor文を使えるのは一回までであると見立てが付く
int main()
{
    cin >> A >> B >> C >> X >> Y;
    int cost = A * X + B * Y;
    for (int i = 0; i <= 100000; i++)
    {
        int s = 2 * C * i + max(0, X - i) * A + max(0, Y - i) * B;
        if (s < cost)
            cost = s;
    }
    cout << cost << endl;
}


Measured memory_bytes: 3604
from collections import deque
k = int(input())
q = deque([1,2,3,4,5,6,7,8,9])
for i in range(k):
  x = q.popleft()
  y = x%10
  if y != 0:
    q.append(10*x+y-1)
  q.append(10*x+y)
  if y != 9:
    q.append(10*x+y+1)
print(x)

Measured memory_bytes: 40816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int cnt(string s) {
    int res = 0;
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] == 'A' && s[i+1] == 'B') res++;
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int N; cin >> N;
    int ans = 0;
    int endA = 0, startB = 0, both = 0;
    for (int i = 0; i < N; i++) {
        string s; cin >> s;
        ans += cnt(s);
        if (s[0] == 'B' && s.back() == 'A') both++;
        else if (s[0] == 'B') startB++;
        else if (s.back() == 'A') endA++;
    }
    if (both > 0) {
        ans += both-1;
        if (endA > 0) {
            endA--;
            ans++;
        }
        if (startB > 0) {
            startB--;
            ans++;
        }
    }
    ans += min(endA,startB);
    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
A = [int(i) for i in input().split()]
divNo = [0] * N
for i in range(N):
  while A[i]%2 == 0:
    A[i] = A[i]/2
    divNo[i] += 1
print(min(divNo))

Measured memory_bytes: 3188
using namespace std;
#include <bits/stdc++.h>
#define frr(i, r, l) for(int i = r; i >= l; --i)
#define fr(i, l, r) for(int i = l; i < r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
typedef pair<ll, ll> iPair; 
priority_queue< ll, vector <ll> , greater<ll>>pq1,pq2;
#define maxN 1000000000000000000
ll power(ll a,ll b){ll res=1;while(b>0){res*=a;b--;}return res;}
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,r1[200005],w1[200005],ans,cnt1=0,cnt2=0;
    string str;
    cin>>n;
    cin>>str;
    fr(i,0,n)
    {
        if(str[i]=='R')
        cnt1++;
        else
        cnt2++;

        r1[i]=cnt1;
        w1[i]=cnt2;
    }
    ans=cnt1;

    frr(i,n-1,0)
    {
        ll st1=w1[i];
        ll st2=cnt1-r1[i];
        ll st3=max(st1,st2);

        ans=min(ans,st3);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  
  int ans=a*x+b*y;
  int harf=max(x,y)*c*2;
  if(harf<ans)ans=harf;
  int plus=max(x,y)-min(x,y);
  int mix=min(x,y)*c*2;
  if(max(x,y)==x){
    mix+=a*plus;
    if(mix<ans)ans=mix;
  }else{
    mix+=b*plus;
    if(mix<ans)ans=mix;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3564
using System;

public class Class1
{
	public static void Main(string[] args)
	{
        string[] input = Console.ReadLine().Split(' ');

        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);

        int min = a + b;

        if(min > a + c)
        {
            min = a + c;
        }

        if (min > b + c)
        {
            min = b + c;
        }

        Console.WriteLine(min);
              
       
	}
}


Measured memory_bytes: 11092
import sys
sys.setrecursionlimit(2001)
n, k = list(map(int, input().split(' ')))
# 5,3,1
# xRxRx | BBB => 3C1
# 5,3,2
# xRxRx | BB, B => 3C2
# xRxRx | B, BB => 3C2 > BBB を２つに分けるのは 2C1
# 5,3,3
# xRxRx | B, B, B => 3C3
#
# 3C1 * 2C0
# 3C2 * 2C1
# 3C3 * 2C2

# 6,4,1
# xRxRx | BBBB => 3C1
# 6,4,2
# xRxRx | BBB, B => 3C2
# xRxRx | BB, BB => 3C2
# xRxRx | B, BBB => 3C2 > BBBB を２つに分けるのは 3C1
# 6,4,3
# xRxRx | BB, B, B => 3C3
# xRxRx | B, BB, B => 3C3
# xRxRx | B, B, BB => 3C3 > BBBB を3つに分けるのは 3C2
# 6,4,4
# REDが2つなので3つまでしか分けられないので0
#
# 3C1 * 3C0
# 3C2 * 3C1
# 3C3 * 3C2
# 3C4 * 3C3 (=0)

# RED + 1 C (i+1) * BLUE-1 C i
# パスカルの三角形と思ったけど2000!が普通に帰ってくるっぽいので
red = n - k
blue = k
memo = {}
def f(i):
    if i not in memo:
        if i <= 1:
            memo[i] = 1
        else:
            memo[i] = i * f(i-1)
    return memo[i]

def choice(a, b):
    if a < b:
        return 0
    return f(a) // f(a-b) // f(b)

mod = int(1e9) + 7
for i in range(k):
    print(choice(red+1, i+1) * choice(blue-1, i) % mod)

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  d.erase(unique(d.begin(), d.end()), d.end());
  cout << d.size() << endl;
}

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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

ll N;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> N;
    if (N % 2) cout << 0;
    else {
        ll ans = 0, factor = 10;
        while (N >= factor) {
            ans += N / factor;
            factor *= 5;
        }
        cout << ans;
    }
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	static int time = 0;

	static int limit = 0;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		limit = n;
		int[] stock = new int[n];

		for (int i = 0; i < n; i++) {
			stock[i] = sc.nextInt();
		}
		sc.close();
		long money = 1000;
		while (time < n - 1) {
			money = stockTrade(money, stock);
		}
		print(money);
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

	public static long stockTrade(long money, int[] stock) {
		while (stock[time] >= stock[time + 1]) {
			time++;
			if (time == limit - 1) {
				return money;
			}
		}
		long stockNum = money / stock[time];
		long residue = money - stockNum * stock[time];
		while (stock[time] <= stock[time + 1]) {
			time++;
			if (time == limit - 1) {
				return residue + stockNum * stock[time];
			}
		}
		return residue + stockNum * stock[time];
	}

}


Measured memory_bytes: 35720
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

vector<int>primes;
void hurui(const int amax) {
	static bool flag = false;
	if (flag)return;
	vector<int>sos;
	sos = vector<int>(amax + 1, true);
	sos[0] = false; sos[1] = false;
	for (int i = 2; i <= amax; ++i) {
		if (sos[i]) {
			for (int j = 2 * i; j <= amax; j += i)sos[j] = false;
		}
	}
	for (int i = 0; i <= amax; ++i) {
		if (sos[i]) {
			primes.push_back(i);
		}
	}
	flag = true;
}

int main() {
	hurui(1 << 16);
	while (1) {
		int N; cin >> N;
		if (!N)break;
		int ans = 0;
		for (int i = 0; i < primes.size(); ++i) {
			int j = N - primes[i];
			if (j < primes[i])break;
			else {
				if (binary_search(primes.begin(), primes.end(), j)) {
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
from collections import deque

while True:
  t, n = map(int, input().split())
  if t==0 and n==0:
      break
  else:
    d = [[-1]*200 for _ in range(200)]
    for i in range(n):
      x, y = map(int, input().split())
      d[x+100][y+100] = float("INF")
    sx, sy = map(int, input().split())
    sx, sy = sx+100, sy+100

    q = deque([])
    q.append((sx, sy))
    d[sx][sy] = 0

    while len(q)>0:
      cur = q.popleft()
      curx, cury = cur[0], cur[1]
      for dx_ in range(-1, 2):
        for dy_ in range(-1, 2):
          if (dx_*dy_==-1) or (dx_==0 and dy_==0):
            continue
          else:
            nx, ny = curx+dx_, cury+dy_
            if d[curx][cury]<t and 0<=nx<200 and 0<=ny<200 and d[nx][ny]==-1:
              q.append((nx, ny))
              d[nx][ny] = d[curx][cury]+1

    ans = 0
    for i in range(len(d)):
      for ele in d[i]:
        if 0<=ele<=t:
          ans+=1
    print(ans)


Measured memory_bytes: 6664
from collections import deque

K = int(input())
count = 0

deq = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

while True:
    num = deq.popleft()
    count += 1
    if num % 10 != 0:
        deq.append((10 * num) + (num % 10) - 1)
    deq.append((10 * num) + (num % 10))
    if num % 10 != 9:
        deq.append((10 * num) + (num % 10) + 1)
    
    if count == K:
        ans = num
        break

print(ans)

Measured memory_bytes: 11872
N, M, K = map(int,input().split())
MOD = 998244353
ans = 0

fac = [1] * (N+1)
finv = [1] * (N+1)
inv = [1] * (N+1)
inv[0] = 0
for i in range(2, N+1):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD//i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD

def comb(n, k):
    if (n < k) or (k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
    
if K == 0:
    ans = (M*pow(M-1, N-1, MOD))%MOD 
if K >= 1:
    ans = ((M*pow(M-1, N-1, MOD))%MOD + (M*pow(M-1, N-2, MOD)*(N-1)))%MOD
if K > 1:
    for i in range(K-1):
        ans = (ans + M*pow(M-1, N-3-i, MOD)*comb(N-1,i+2)%MOD)%MOD
print(ans)

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

template <class lambda_type>
class make_recursive
{
    const lambda_type &func;
public:
    make_recursive(lambda_type &&f) : func(std::move(f)) {}
    template <class... Args> auto operator()(Args &&... args) const
    {
        return func(*this, std::forward<Args>(args)...);
    }
};

main()
{
    int n; cin>>n;
    vector<int> a(n);
    for(auto &e: a) cin>>e;
    vector<vector<int>> tree(n);
    for(int i=0; i<n-1; ++i)
    {
        int u,v; cin>>u>>v; --u,--v;
        tree[v].emplace_back(u);
        tree[u].emplace_back(v);
    }
    vector nlow(n, INT_MAX),ans(n,0);
    make_recursive([&](auto dfs, int v=0, int p=-1)->void
    {
        auto ptr=lower_bound(begin(nlow), end(nlow), a[v]);
        const int plow=*ptr;
        *ptr=a[v];
        ans[v]=lower_bound(begin(nlow), end(nlow), INT_MAX)-begin(nlow);
        for(int u: tree[v]) if(p!=u) dfs(u,v);
        *ptr=plow;
    })();
    for(int e: ans) cout << e << "\n";
}


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

int n;
bool p[10000010];
int k;
int pp[10000000];

void prime() {
	p[0] = 1;
	p[1] = 1;
	for(int i = 2; i <= 10000000; i++) {
		if(p[i]) {
			continue;
		}
		pp[k++] = i;
		for(int j = i * 2; j <= 10000000; j += i) {
			p[j] = 1;
		}
	}
}

int main() {
	cin >> n;
	prime();
	for(int i = 0; i < k; i++) {
		if(pp[i] >= n) {
			cout << pp[i] << endl;
			return 0;
		}
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  
  for(int i=0; i<N; ++i){
    A[i] = i+1;
  }
  
  
  int count = 0;
  
  while(true){
    bool exist_eve = false;
    for (int i=0; i<N; ++i){
      if((A[i] != 0) && (A[i]%2 == 0)) exist_eve = true;
    }
    
    if(exist_eve == false) break;
    
    for(int i=0; i<N; ++i){
      A[i] /= 2;
    }
    ++count;
    exist_eve = false;
  }
    
  int ans = 1;
  for(int i=0; i<count; ++i){
    ans*=2;
  }
  cout << ans << endl;
  
}


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

using namespace std;

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



int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    int count = 0;
    rep(i, n) {
        if (a[i] == count + 1){
            count++;
        }
    }
    if (count == 0){
        cout << -1 << endl;
    }else{
        cout << n - count << endl;
    }
    
    
}

Measured memory_bytes: 1024
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int[] data = new int[n];
    int max = 0;

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      data[i] = a[i];
      max = Math.max(max,a[i]);
    }

    Arrays.sort(data);

    for (int i = 0; i < n; i++) {
      if (a[i] != max) {
        System.out.println(max);
      } else {
        System.out.println(data[n-2]);
      }
    }

  }

}


Measured memory_bytes: 94464