akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long ll;
const ll MOD = 1000000007;

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

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

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

    ll sumx = 0;
    for(ll i = 0; i < n; i++){
        sumx = sumx + ((2 * i - n + 1) * x[i]) % MOD;
        sumx %= MOD;
    }

    ll sumy = 0;
    for(ll i = 0; i < m; i++){
        sumy = sumy + ((2 * i - m + 1) * y[i]) % MOD;
        sumy %= MOD;
    }

    ll sum = (sumx * sumy) % MOD;

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1792
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	ans := 0.0
	for i := 0; i < n; i++ {
		x, u := nextFloat64(), next()
		if u == "BTC" {
			x *= 380000.0
		}
		ans += x
	}
	fmt.Println(ans)
}


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

using ll =long long;

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

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

int main()
{
int X;
  cin>>X;
  if(X==3||X==5||X==7){
    cout<<"YES"<<endl;
  }else{cout<<"NO"<<endl;}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
using namespace std;
const int INF=LLONG_MAX-1e10;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;

main()
{
    IOS
    fu(i,1,3)cin>>a[i];
    b[1]=a[2]/a[1];
    b[2]=a[3]/a[1];
    out(b[1]==b[2] && a[2]%a[1]!=0 && a[3]%a[1]!=0?"NG":"OK")
    return 0;
}


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

int main(){
  long long a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  long long d = abs(a-b);
  bool judge = false;
  
  if(v > w){
    if(d <= t * (v-w)){
      judge = true;
    }
  }
  
  if(judge){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 59; //MAX 9223372036854775807


int main()
{
ll n,k;
scanf("%lld%lld", &n, &k);
ll t[n] = {};
rep(i, n){
    scanf("%d", &t[i]);
}
pair<ll,ll> to[n];
{vector<ll> bac(200001,0);
vector<ll> flo(200001,-1);
rep(i,n){
    to[n-i-1].first=bac[t[n-i-1]];
    bac[t[n-i-1]]=n-i-1;
}
rep(i,n){
    if(flo[t[i]]==-1)flo[t[i]]=i;
}
rep(i,n){
    if(to[i].first==0){to[i].first=flo[t[i]];to[i].second=1;}
    if(to[i].first==n-1)to[i].second=1;
    to[i].first=to[i].first+1;
    if(i==n-1&&to[i].first==n)to[i].second++;
    to[i].first%=n;
}
}
vector<ll> v;
set<ll> st;
v.push_back(0);
st.insert(0);
ll sy=0;
while(1){
    ll too=to[v.back()].first;
    auto r = st.insert(too);
    if(r.second){sy+=to[v.back()].second;v.push_back(too);}
    else {sy+=to[v.back()].second;break;}
}
k%=sy;
if(k==0)return 0;
ll str=0;
ll now=0;
vector<ll> ans;
while(1){
    now+=to[str].second;
    if(k>now)str=to[str].first;
    else{
        
        for (ll i = str; i < n; i++)
        {
            ans.push_back(t[i]);
        }
        break;
    }
}

vector<ll> anss;
set<ll> stt;
rep(i,ans.size()){
    auto r =stt.insert(ans[i]);
    if(r.second)anss.push_back(ans[i]);
    else{
        while(1){
            if(ans[i]==anss.back())break;
            stt.erase(anss.back());
            anss.pop_back();
        }
        stt.erase(anss.back());
        anss.pop_back();
    }
}



for (int aa : anss) printf("%d ", aa);
return 0;
}


Measured memory_bytes: 29640
import sys

inf = 1<<30
lim = 10**5

def solve():
    cubics = [x**3 for x in range(100 + 1)]

    while 1:
        e = int(sys.stdin.readline().rstrip())

        if e == 0:
            return

        ans = inf

        for z, c in enumerate(cubics):
            if c > e:
                break
            y = int((e - c)**0.5)
            x = e - c - y**2
            ans = min(ans, x + y + z)

        print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 8252
n, p=map(int,input().split())
ans = 0
if n != 1:
    for i in range(1,int((p+1)**(1/n))+1):
        ni = i**n
        if p/ni >= 1 and p/ni == int(p/ni):
            ans = i
        elif p/ni < 1:
            break
    print(ans)
else:
    print(p)

Measured memory_bytes: 40428
#include<iostream>
#include<set>
using namespace std;
int main()
{
 
int x,ans=0;
cin>>x;
int s[111];
for(int i=0;i<x;i++)
    cin>>s[i];

ans=x;
for(int i=0;i<x;i++)
for(int j=0;j<i;j++)
    if(s[i]==s[j]) {ans--;
                    break;}
cout<<ans;

system("pause");
return 0;
}

Measured memory_bytes: 504
#include <stdio.h>

#define Num 100

int main(void){

    int l, n, i, j, k;
    int a[Num];

    scanf("%d", &l); 

    for (i = 0; i <= l-1; i++) {
        scanf("%d", &a[i]); 
    }

    for (i = 0; i <= l-1; i++) {
        j = i - 1;
        while (j>=0){
            if(a[j] > a[j+1]){
                n = a[j+1];
                a[j+1] = a[j];
                a[j] = n;
            }
            j--; 
        }
        for (k = 0; k <= l-2; k++) {
            printf("%d ", a[k]);
        }
        printf("%d\n", a[k]);
    }

    return 0;
}


Measured memory_bytes: 1928
N, M, X, Y = map(int, input().split())
x_list = map(int, input().split())
y_list = map(int, input().split())

x_max = max(x_list)
y_min = min(y_list)

war_flag = True
for z in range(x_max + 1, y_min + 1):
    if X < z <= Y:
        war_flag = False
        break

if war_flag:
    print("War")
else:
    print("No War")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int cnt[4] = {};
    rep(i, S.length()) {
        if (S[i] == 'N') cnt[0]++;
        if (S[i] == 'W') cnt[1]++;
        if (S[i] == 'S') cnt[2]++;
        if (S[i] == 'E') cnt[3]++;
    }
    rep(i, 2){
        if (cnt[0+i] * cnt[2+i] == 0 && cnt[0+i] + cnt[2+i] > 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		if(a+b<24) {
			System.out.println(a+b);
		}else {
			System.out.println(a+b-24);
		}
	}
}

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

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var h = Console.ReadLine()
                .Split(' ')
                .Select(int.Parse)
                .ToList();

            var count = 0;

            for (int i = 0; i < h.Count; i++)
            {
                for (int j = 0; j <= i; j++)
                {
                    if (i == 0 && j == 0)
                    {
                        count++;
                        break;
                    }

                    if (h[j] <= h[i])
                    {
                        if (i == j)
                        {
                            count++;
                        }
                        continue;
                    }
                    else
                    {
                        break;
                    }

                }
            }

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,y;
    cin>>n>>x>>y;
    int u = min(x,y);
    int v = max(x,y);
    int k[n];
    for(int i=0;i<n;i++)
        k[i]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            int dist;
            dist = min(abs(j-i),min(abs(i-u)+1+abs(v-j),abs(i-v)+1+abs(u-j)));
            k[dist]++;
        }
    }
    for(int i=1;i<n;i++)
        cout<<k[i]<<" ";
    cout<<"\n";
    return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

constexpr static int MOD = 1000000000 + 7;
constexpr static int inf = INT_MAX / 2;
constexpr static llong INF = 1LL << 31;
constexpr static int dx[] = {1, 0, -1, 0};
constexpr static int dy[] = {0, 1, 0, -1};

vector<int> C, visited, ans;
vector<vector<int> > G;
void dfs(int v) {
    if(visited[v]) return;

    visited[v] = 1;
    ans.push_back(v);
    rep(i, (int)G[v].size()) {
        dfs(G[v][i]);
    }
}

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<pair<int, int> > tree(n);
    rep(i, n) {
        tree[i].first = 0;
        tree[i].second = i;
    }
    G.resize(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        ++tree[a].first, ++tree[b].first;
        G[a].push_back(b), G[b].push_back(a);
    }
    sort(allr(tree));
    int maximum = -1;
    llong sum = 0;
    C.resize(n);
    rep(i, n) {
        int c;
        cin >> c;
        C[i] = c;
        sum += c;
        maximum = max(maximum, c);
    }
    sort(allr(C));
    visited.resize(n, 0);
    dfs(tree[0].second);

    vector<int> res(n);
    cout << sum - maximum << endl;
    rep(i, n) {
        res[ans[i]] = C[i];
    }

    rep(i, n) {
        if (! i) cout << res[i];
        else cout << " " << res[i];
    }
    cout << endl;

    return 0;
}

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

dp = [0]*N #勇者が倒す数

for i in range(N):
  dp[i] = min(A[i], B[i])
  A[i] -= dp[i]
  B[i] -= dp[i]
  rem = A[i]
  if rem==0:
    tmp = min(A[i+1], B[i])
    dp[i] += tmp
    A[i+1] -= tmp
print(sum(dp))

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

#define OUTINF "infinity"

int main(void) {
	long long T1, T2, A1, A2, B1, B2;
	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

	// T1+T2経過後の位置
	A1 = A1*T1, A2 = A2*T2;
	B1 = B1*T1, B2 = B2*T2;
	if ((A1+A2)<(B1+B2)) {swap(A1,B1); swap(A2,B2);}
	// 差がつかない
	if ((A1==B1) || ((A1+A2)==(B1+B2))) {
		cout << OUTINF << endl;
		return 0;
	}
	// 一度も交差しない
	if ((A1-B1)>0) {
		cout << 0 << endl;
		return 0;
	}

	// 2回目のT1での差
	long long T1T1dif = 2*(A1-B1)+(A2-B2);
	// T1-T1間で縮まる距離
	long long interval = (A1-B1)-T1T1dif;
	long long cnt = ((A1-B1)/interval)*2 + 1; // x2足す分
	if (((A1-B1)%interval)==0) { // 最後の1回が追い抜かない
		cnt -= 1;
	}
	cout << cnt << endl;
	return 0;
}


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

int main(){
    int n, m;
    bool board[2020] = {0};
    int x[101];
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> x[i];
        board[x[i]] = true;
    }
    cin >> m;
    for(int i=0;i<m;i++){
        int a;
        cin >> a;
        if(x[a]==2019 || board[x[a]+1]) continue;
        board[x[a]] = false;
        board[x[a]+1] = true;
        x[a]++;
    }

    for(int i=1;i<=n;i++) cout << x[i] << endl;
    return 0;
}


Measured memory_bytes: 3116
import math
A, B, C, D = input().split(' ')

takahasi_tairyoku = int(A)
aoki_tairyoku = int(C)

takahasi_kougeki = int(B)
aoki_kougeki = int(D)

takahasi_count = math.ceil(aoki_tairyoku / takahasi_kougeki) # 高橋はアオキを何回で倒せるか
aoki_count = math.ceil(takahasi_tairyoku / aoki_kougeki) # アオキは高橋を何回で倒せるか
# print(takahasi_count, aoki_count)
if (takahasi_count <= aoki_count):
  print('Yes')
else:
  print('No')

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

using namespace std;
vector<int>p;
int main ()
{
    int n;
    cin>>n;
    vector <int>a(n);
    for(int i=0;i<n;i++)
    cin>>a[i],a[i]*=-1;//颠倒顺序，往前找大的值

    for(int i=0;i<n;i++)
    {
        int tmp=upper_bound(p.begin(),p.end(),a[i])-p.begin();
        if(tmp==p.size())//全都比其小
        p.push_back(a[i]);//
        else
        p[tmp]=a[i];
    }
    cout<<p.size();

    return 0;
}


Measured memory_bytes: 1276
from collections import deque


def bfs(rooms, v=1):
    arrow = [-1] * len(rooms)
    q = deque()
    q.append(v)

    while q:
        now = q.popleft()
        for next_v in rooms[now]:
            if arrow[next_v] != -1:
                continue
            else:
                q.append(next_v)
                arrow[next_v] = now
    return arrow


def main():
    n, m = map(int, input().split())
    rooms = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        rooms[b].append(a) 
        rooms[a].append(b)

    anss = bfs(rooms)
    print("Yes")
    for ans in anss[2:]:
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 34696
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

int A[10];
int main()
{
    for(int i = 0; i < 10; i ++)
    {
        cin >> A[i];
    }
    
    sort(A, A + 10);
    cout << A[9] << endl;
    cout << A[8] << endl;
    cout << A[7] << endl;
    return 0;
}

Measured memory_bytes: 3140
n, m = map(int, input().split())
C = list(map(int, input().split()))
dp = [100000] * (n + 1)
dp[0] = 0
for k in C:
    for i, t in enumerate(zip(dp[k:], dp), start = k):
        a, b = t
        dp[i] = min(a, b + 1)
print(dp[n])

Measured memory_bytes: 11456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  unordered_map<int,int> map;
  rep(i, N) {
    int a; cin >> a;
    map[a]++;
  }
  
  int ans = 0;
  
  for(auto p : map) {
    if(p.second%2 == 1) ans++;
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 4388
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
typedef pair<ll,ll> P;
#define N 100010
ll n,m,p,h[N];
vector<P> v[N];

ll d[N];
priority_queue<P> Q;
void Dijkstra(){
    fill(d,d+N,-(ll)mod*(ll)mod);
    Q.push(make_pair(p,1));
    while(!Q.empty()){
	ll cost=Q.top().first;
	ll x=Q.top().second;
	Q.pop();
	if(d[x]>=cost)continue;
	if(cost>h[x]){
	    Q.push(make_pair(h[x],x));
	}
	else{
	    for(auto u:v[x]){
		Q.push(make_pair(cost-u.second,u.first));
	    }
	    d[x]=cost;
	}
    }
}
int main(){
    cin>>n>>m>>p;
    lol(i,n)cin>>h[i+1];
    lol(i,m){
	ll a,b,x;cin>>a>>b>>x;
	if(h[a]>=x)v[a].push_back(make_pair(b,x));
	if(h[b]>=x)v[b].push_back(make_pair(a,x));
    }
    Dijkstra();
    if(d[n]==-(ll)mod*(ll)mod)cout<<"-1"<<endl;
    else cout<<p-d[n]+h[n]-d[n]<<endl;
    //lol(i,n)cout<<d[i+1]<<" ";cout<<endl;
    return 0;
}



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

int main() {
	int num[3], k;

	cin >> num[0] >> num[1] >> num[2];
	cin >> k;

	sort(num, num + 3);
	for (int i = 1; i <= k; i++) {
		num[2] *= 2 ;
	}
	cout << num[0] + num[1] + num[2] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
signed main(){
	int n;
	int a[111111];
	int ans=0;
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	reverse(a,a+n);
	rep(i,n){
		if(i%2==0)ans+=a[i];
		else ans-=a[i];
		
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))

a1_sum = [0]*n
a2_sum = [0]*n

a1_sum[0] = a1[0]
a2_sum[0] = a2[-1]

for i in range(1,n):
    a1_sum[i] = a1_sum[i-1] + a1[i]
    a2_sum[i] = a2_sum[i-1] + a2[-i-1]
print(max(x+y for x,y in zip(a1_sum,a2_sum[::-1])))

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

using namespace std;

int main()
{
	long long a,b,x,c,d,ans=0;
	cin>>a>>b>>x;
	if(a%x==0)
	c=a;
	else
	c=x*(a/x+1);
	d=b-(b%x);
	ans=(d-c)/x;
	
	
	
	cout<<ans+1<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long pow(long long p,long long q,long long r){
  if(q==0)return 1;
  else if(q%2==0)return pow(p,q/2,r)*pow(p,q/2,r)%r;
  else return pow(p,q-1,r)*p%r;
}
long long pCq(long long p,long long q,long long r){
  if(q==0)return 1;
  else {
    return pCq(p,q-1,r)*(p-q+1)%r*pow(q,r-2,r)%r;
  }
}
int main() {
  long long n,a,b,ans=0;
  cin>>n>>a>>b;
  long long mod=1000000007;
  ans=pow(2,n,mod)-1-pCq(n,a,mod)-pCq(n,b,mod);
  while(ans<0)ans+=mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 6528
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nd = readln.split.to!(int[]);
    auto N = nd[0];
    auto D = nd[1];
    auto d = D*2+1;
    writeln((N+d-1) / d);
}

Measured memory_bytes: 256
n,m = map(int, input().split())
redl = [False]*(n+1)
redl[1] = True
cnts = [1]*(n+1)
cnts[0] = 1

for _ in range(m):
    x,y = map(int, input().split())
    if redl[x]: redl[y] = True
    if cnts[x] == 1: redl[x] = False
    cnts[x] -= 1
    cnts[y] += 1

ans = redl.count(True)
print(ans)

Measured memory_bytes: 76260
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#define MAX 1000001
bool isprime[MAX];
int p[MAX];

void prime(){
	int i,j,np=0;
	memset(isprime,0,sizeof(isprime));
	memset(p,0,sizeof(p));
	for(i=2;i<=MAX;i++){
		if(!isprime[i]) p[np++]=i;
		for(j=0;j<np&&p[j]*i<=MAX;j++){
			isprime[p[j]*i]=1;
			if(i%p[j]==0) break;
		}
	}
	isprime[1]=1;
	isprime[0]=1;
}

int main(void){
	int a,d,n;
	int i;
	int j,dq;
	prime();
	while(scanf("%d %d %d",&a,&d,&n)==3){
		if(a==0&&d==0&&n==0) break;
		j=0;
		for(i=0;;i++){
			dq=a+i*d;
			if(isprime[dq]==0){
				j++;
				if(j==n){
					printf("%d\n",dq);
					break;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 6632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    // input
    char c;
    cin >> c;
    vector<char> vowels{'a', 'i', 'u', 'e', 'o'};
    bool hit = false;
    for (const auto& v:vowels) {
        if (v == c){
            cout << "vowel" << endl;
            return 0;
        } 
    }
    cout << "consonant" << endl;;
    return 0;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    n %= 10;
    if(n == 3){
        puts("bon");
    }else if(n == 0 or n == 1 or n == 6 or n == 8)puts("pon");
    else puts("hon");
}


Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<queue>
#include<set>

using namespace std;
typedef pair<int,int> PII;

int	card[40320];

int perm2num(vector<int> perm){
	int num=0;
	for(int i=0;i<8;i++){
		num *= 8-i;
		num += perm[i];
		for(int j=i+1;j<8;j++){
			if(perm[j]>perm[i])perm[j]--;
		}
	}
	return num;
}

void solve(){
	vector<int> bgn(10);
	for(int i=0;i<8;i++) bgn[i] = i;
	vector<int> tmp(10);
	queue<vector<int> > qu;
	qu.push(bgn);
	while(!qu.empty()){
		tmp = qu.front();
		//int b=0;
		//for(;b<8;b++) if(tmp[b] != 7-b)break;
		//if(b==8)break;
		qu.pop();
		if(tmp[8]<4){
			swap(tmp[tmp[8]],tmp[tmp[8]+4]);			
			tmp[9]++;
			tmp[8]+=4;
			if (card[perm2num(tmp)]==-1){
				qu.push(tmp);
				card[perm2num(tmp)] = tmp[9];
			}
			tmp[9]--;
			tmp[8]-=4;
			swap(tmp[tmp[8]],tmp[tmp[8]+4]);			
		}
		else{
			swap(tmp[tmp[8]],tmp[tmp[8]-4]);			
			tmp[9]++;
			tmp[8]-=4;
			if (card[perm2num(tmp)]==-1){
				qu.push(tmp);
				card[perm2num(tmp)] = tmp[9];
			}
			tmp[9]--;
			tmp[8]+=4;
			swap(tmp[tmp[8]],tmp[tmp[8]-4]);			
		}
		if(tmp[8]%4>0){
			swap(tmp[tmp[8]],tmp[tmp[8]-1]);			
			tmp[9]++;
			tmp[8]--;
			if (card[perm2num(tmp)]==-1){
				qu.push(tmp);
				card[perm2num(tmp)] = tmp[9];
			}
			tmp[8]++;
			swap(tmp[tmp[8]],tmp[tmp[8]-1]);			
			tmp[9]--;
		}
		if(tmp[8]%4<3){
			swap(tmp[tmp[8]],tmp[tmp[8]+1]);			
			tmp[9]++;
			tmp[8]++;
			if (card[perm2num(tmp)]==-1){
				qu.push(tmp);
				card[perm2num(tmp)] = tmp[9];
			}
			tmp[8]--;
			tmp[9]--;
			swap(tmp[tmp[8]],tmp[tmp[8]+1]);			
		}
	}
}

int main(){
	card[0] = 0;
	for(int i=1;i<40320;i++) card[i] = -1;
	solve();
	vector<int> perm(8);
	while(true){
		int i=0;
		for(;i<8;i++){
			if(!(scanf("%d",&perm[i])+1))break;
		}
		if(i<8)break;
		cout<<card[perm2num(perm)]<<endl;
	}
	
  return 0;
}

Measured memory_bytes: 1084
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 2345;
const LL MOD = 998244353;

LL C[3 * MAXN][MAXN], H[MAXN][MAXN];
LL fin[2 * MAXN];

int main() {
    for (int i = 0; i < MAXN * 3; i++) {
        for (int j = 0; j < MAXN; j++) {
            if (!j) C[i][j] = 1;
            else if (!i) C[i][j] = 0;
            else C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
        }
    }
    //H[i][j] means number of way of (take i nums in j elements)
    for (int i = 0; i < MAXN; i++) {
        for (int j = 0; j < MAXN; j++) {
            if (!i) H[i][j] = 1;
            else if (!j) H[i][j] = 0;
            else H[i][j] = C[i + j - 1][j - 1];
        }
    }
    H[0][0] = 1;
    int N, K;
    while (~scanf("%d %d", &K, &N)) {
          for (int i = 2; i <= 2 * K; i++) {
              int offset = K + 1;
              if (i > offset) {
                 printf("%lld\n", fin[offset * 2 - i]);
                 continue;
              }
              LL ans = 0;
              LL bk = i / 2;
              if (i % 2 == 0) bk--;
              for (int j = 0; j <= bk; j++) {
                  //if i is even, we enumerate the case take i / 2, and not take i / 2
                  LL rem = K - bk - j;
                  if (j > N) continue;
                  if (i % 2 == 0) {
                     rem--;
                     // take the j / 2 th number
                     LL tmp = (C[bk][j] * H[N - 1 - j][rem + j]) % MOD;
                     //printf("i = %d j = %d tmp = %lld\n", i, j, tmp);
                     ans += tmp;
                  }
                  ans %= MOD;
                  LL cnt = (C[bk][j] * H[N - j][rem + j]) % MOD;
                  //printf("i = %d j = %d bk = %lld rem = %lld cnt = %lld\n", i, j, bk, rem, cnt);
                  ans += cnt;
                  ans %= MOD;
              }
              fin[i] = ans;
              printf("%lld\n", ans);
          }
    }

    return 0;
}


Measured memory_bytes: 172160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int WA[100100];
bool AC[100200];

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

    int ac = 0;
    int pena = 0;
    rep(i, n) {
        WA[i] = 0;
        WA[i] = false;
    }
    rep(i, m) {
        int P;
        string S;
        cin >> P >> S;
        if (AC[P-1]) continue;
        if (S == "AC") {
            AC[P-1] = true;
            ac++;
            pena += WA[P-1];
        }
        else WA[P-1]++;
    }
    cout << ac << ' ' << pena << endl;
    return 0;
}

Measured memory_bytes: 4028
N = int(input())
S = list(input())
Q = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"
num = dict()
for i, var in enumerate(alphabet):
  num[var] = i

class Bit():
  def __init__(self, N):
    self.__N = N
    self.__arr = [[0] * 26 for _ in range(1 + N)]
    
  def add_(self, x, a, i):
    while(x < self.__N + 1):
      self.__arr[x][i] += a
      x += x & -x
      
  def sum_(self, x, i):
    res = 0
    while(x > 0):
      res += self.__arr[x][i]
      x -= x & -x
    return res
  
  def sub_sum_(self, x, y, i):
    return self.sum_(y, i) - self.sum_(x, i)

Bit = Bit(N)
for i, var in enumerate(S):
  Bit.add_(i+1, 1, num[var])

for i in range(Q):
  q, l, r = input().split()
  l = int(l)
  if q == "1" and r != S[l-1]:
    temp = S[l-1]
    S[l-1] = r
    Bit.add_(l, -1, num[temp])
    Bit.add_(l, 1, num[r])
  elif q == "2":
    r = int(r)
    res = 0
    for j in range(26):
      res += min(1, Bit.sub_sum_(l-1, r, j))
    print(res)    
    


Measured memory_bytes: 257260
#=============================================================================
# Breadth First Search
#=============================================================================
import queue

N=int(input())
Graph=[[] for _ in range(N+1)]
dist=[-1 for _ in range(N+1)]
for i in range(1,N+1):
    Graph[i]=list(map(int,input().split()))[2:]


que=queue.Queue()
que.put(1)
dist[1]=0
while not que.empty():
    v=que.get()
    for nv in Graph[v]:
        if dist[nv] != -1:
            continue
        dist[nv]=dist[v]+1
        que.put(nv)
for i in range(1,N+1):
    print(i,dist[i],sep=" ")



Measured memory_bytes: 6876
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    string s;
    cin >> s;
	string t ="AKIHABARA";

    rep(i,0,sz(t)){
        if(s[i] != t[i]){
            if(s[i] != 'A'){
                s.it(s.begin()+i,'A');
                i--;
            }else{
                NO;
                ret 0;
            }
        }
    }
    if(s == t)YES;
    else NO;
    
	return  0;
}

Measured memory_bytes: 256
#include <iostream>

#define INF 100000000000

using namespace std;

int main(){
	long x, y;
	cin>>x>>y;
	long ans1=0, ans2=0, ans3=0, ans4=0;
	ans1 = y-x>=0?y-x:INF;
	ans2 = y+x>=0?y+x+1:INF;
	ans3 = -y-x>=0?-y-x+1:INF;
	ans4 = -y+x>=0?-y+x+2:INF;
	cout<<min(min(min(ans1, ans2) ,ans3), ans4)<<endl;
	return 0;
}


Measured memory_bytes: 256
while True:
    a=0
    b=0
    n=input()
    if n=='0':
        break
    for i in range(1,len(n)):
        if n[i]=='A':
            a+=1
        else:
            b+=1
    if a>b:
        a+=1
    else:
        b+=1
    print(a,b)


Measured memory_bytes: 5556
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define int long long
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%lld",&a)
#define getII(a,b) scanf("%lld%lld",&a,&b)
#define getIII(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define VgetI(n) int (n); scanf("%lld",&(n))
#define VgetII(n,m) int (n),(m); scanf("%lld%lld",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define INF 2000000000
int n,m,cnt;
bool vis[200005];
vector<int> adj[200005];
void dfs(int u){
	cnt++;
	vis[u]=1;
	for(auto v:adj[u]) if(!vis[v]) dfs(v);
}
main(){
	while(~getII(n,m)){
		FE(i,1,n){
			adj[i].clear();
			vis[i]=0;
		}
		F(i,0,m){
			VgetII(u,v);
			adj[u].pb(v);
			adj[v].pb(u);
		}
		int ans=0;
		FE(i,1,n) if(!vis[i]){
			cnt=0;
			dfs(i);
			ans=max(ans,cnt);
		}
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 21084
//Author: QOEINDIEDIS
//Date: 09-23-2019
#include <bits/stdc++.h>
#define fill(x,c) memset(x,c,sizeof(x))
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long ll;
const long long LL_INF = (long long) 2e18 + 5;
const int SIZE = 1e6+10;
ll n;
ll a[SIZE];
int main(){
	cin>>n;
	ios::sync_with_stdio(false);
    cin.tie(0);
	/*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	*/
	for(int i=1;i<=9;i++)
	{
		for(int j=1;j<=9;j++)
		{
			if(i*j==n){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}




Measured memory_bytes: 256
N = int(input())
C = []
S = []
F = []
for i in range(N - 1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)


def solve(n):
    tmp = 0
    for i in range(n, N - 1):
        if tmp <= S[i]:
            tmp = S[i]
            tmp += C[i]
        else:
            tmp = ((tmp - 1) // F[i] + 1) * F[i]
            tmp += C[i]
    return tmp


for i in range(N):
    print(solve(i))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int k,s,ans;
int main(){
    cin>>k>>s;
    for (int i=0; i<=k; i++) {
        for (int j=0; j<=k; j++) {
            if (s-(i+j)>=0&&s-(i+j)<=k)ans++;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
// Author: πα

#include <bits/stdc++.h>
using namespace std;
#define long int64_t
const int MOD = 1000000007;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> dp(k+1);
    dp[0] = 1;
    while(n--)
    {
        int a;
        vector<int> cur(k+1), pre = dp;
        pre.insert(pre.begin(), 0);
        for(int i = 1; i <= k+1; ++i)
            pre[i] += pre[i-1], pre[i] %= MOD;
        cin >> a;
        for(int j = 0; j <= k; ++j)
        {
            int l = max(0, j-a), r = j+1;
            int x = (pre[r] - pre[l] + MOD) % MOD;
            cur[j] += x, cur[j] %= MOD;
        }
        dp = cur;
    }
    cout << dp[k];
    return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;


int main() {
    int x;cin>>x;
    int n=x/100; //n=買う数の上限
    int r=x%100; //r=合計金額を100で割った余り

    for (int i=0;i<=n;i++) {
        if(r<=5*n){
            cout<<1<<endl;
            return 0;
        //買う数を0から上限まで見ていき、100で割った余りが買う数×0～5ならOK
        }
    }
    cout<<0<<endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     int t,arr[100];
     double sum;
     cin>>t;
     for(int i=0;i<t;i++)
        cin>>arr[i];
     sort(arr,arr+t);
     sum=arr[0];
     for(int i=1;i<t;i++)
     {
         sum=((sum+arr[i])/2.0);
     }
     cout<<sum<<endl;
}


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)


void Main() {
  int k;
  cin >> k;
  if (k<10) {
    cout << k << endl;
    return;
  }
  int now = 9;
  queue<ll> A;
  rep(i, 9) A.push(i+1);
  ll ans = 0;
  while(1) {
    ll a = A.front(); A.pop();
    int b = a % 10;
    if (b != 0) {A.push(a*10+b-1); now++;}
    if (now == k) {
      ans = a*10+b-1;
      break;
    }
    A.push(a*10+b);
    now++;
    if (now == k) {
      ans = a*10+b;
      break;
    }
    if (b != 9) {A.push(a*10+b+1); now++;}
    if (now == k) {
      ans = a*10+b+1;
      break;
    }
  }
  cout << ans << endl;
}

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


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a==0){
		//a==0
		if (b==0){
			if (c==0){
				cout << "Close" << endl;
			}else {
				cout << "Open" << endl;
			}
		}else {
			cout << "Close" << endl;
		}
	}else{
		//a==1
		if (b==0){
			cout << "Close" << endl;
		}else{
			cout << "Open" << endl;
		}
	}
	cin >> c;
}

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

using namespace std;

int main()
{

  int A, B;
  bool ans;
  ans = true;
  cin >> A >> B;

  for (int i = 1; i <= 1001; i++)
  {
    if (int(i * 0.08) == A && int(i * 0.1) == B)
    {
      cout << i << endl;
      ans = false;
      break;
    }
  }

  if (ans)
  {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
import numpy as np
x, y = map(int, input().split())

a = np.array([[2, 4], [1, 1]])
b = np.array([y, x])
c, d = np.linalg.solve(a, b)
c = int(c)
d = int(d)

if c + d == x and c >= 0 and d >= 0:
    print("Yes")
else:
    print("No")

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

int main() {
  ll n,m,tt=1;
  while(cin >> n >> m && n) {
    ll dp[n+1],a[n];
    fill(dp,dp+n+1,1LL<<60);
    dp[0]=0;
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) {
      ll s=0;
      for(int j=i; j<n; j++) {
        s+=a[j];
        ll d=abs(s-m);
        if(j+1==n) d=max(0LL,s-m);
        dp[j+1]=min(dp[j+1],dp[i]+d);
      }
    }
    cout << "Case " << tt++ << ": " << dp[n] << endl;
  }
  return 0;
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

ll fact[200005];

ll p(ll x, ll n) {
	ll res=1;
	while(n) {
		if(n&1) res=(res*x)%MOD;
		x=(x*x)%MOD;
		n/=2;
	}
	return res;
}

ll nCr(ll n, ll r) {
	ll ans=1,i;
	//ll cut=(n-r);
	for(i=n;i>n-r;i--) ans=(ans*i)%MOD;
	//ans = (ans*fact[n])%MOD;
	ans = (ans*p(fact[r],MOD-2))%MOD;
	//ans=(ans*p(fact[n-r],MOD-2))%MOD;
	return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,a,b,i;
    cin >> n >> a >> b;
    fact[0]=1;
    for(i=1;i<200005;i++) {
    	fact[i]=(fact[i-1]*i)%MOD;
    }
    ll ans = (p(2,n)-1+MOD)%MOD;
    //cout << nCr(n,a) << "\n";
    ans = (ans-nCr(n,a)+MOD)%MOD;
    //cout << nCr(n,b) << "\n";
    ans = (ans-nCr(n,b)+MOD)%MOD;
    cout << ans << "\n";
    return 0;
}



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

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define rd(n) scanf("%d", &n)

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

ll f(ll a, ll b)
{
    if(a > b) swap(a, b);
    if(b%a == 0) return 2LL*a*(b/a) - a;
    return 2LL*a*(b/a) + f(a, b%a);
}

int main()
{
    ll n, x; in >> n >> x;
    out << n + f(n-x, x);

    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::collections::HashMap;
use std::mem;
use std::cmp;

fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

fn main(){
    let arr = read_ints();
    let (n,nc) = (arr[0],arr[1]);
    let mut tables = Vec::new();
    let max_time = 100001 as usize;
    for i in 0..nc as usize{
        tables.push(vec![0;max_time*2]);
    }
    
    
    for i in 0..n as usize{
        let arr = read_ints();
        
        let s = (arr[0]-1) as usize;
        let t = (arr[1]-1) as usize;
        let c = (arr[2]-1) as usize;
        
        tables[c][(2*s  ) as usize]=1;
        tables[c][(2*t+1) as usize]=-1;
    }
    
    let mut ans = 0;
    let mut cnt = 0;
    
    
    for j in 0..nc as usize{
        for i in 0..max_time{
            if tables[j][2*i] == 1 && tables[j][2*i+1] == -1{
                tables[j][2*i+1] = 0;
                tables[j][2*i  ] = 0;
            }
        }
    }
    
    for i in 0..(2*max_time) as usize{
        for j in 0..nc as usize{
            cnt += tables[j][i];
        }
        ans = cmp::max(ans,cnt);
    }
    
    println!("{}",ans);
    
    /*
    let starts = Vec::new();
    let ends = Vec::new();
    let channels = Vec::new();
    
    for i in 0..n as usize{
        let arr = read_ints();
        starts.push(arr[0]);
        ends.push(arr[1]);
        channels.push(arr[2]-1);
    }*/
}

/*
struct Uf{
    n_size: usize,
    par   : Vec<i32>,
    rank  : Vec<i32>,
}

impl Uf{
    fn new(n_size:usize) -> Uf{
        Circle{
            n_size:n_size,
            par  :(0..n_size).collect(),
            rank :vec![0;n_size]
        }
    }
    
    fn find(&self, x: i64)->i64{
        let h = self.hash(x);
        
        if( par[h] == x ){
            x
        }else{
            par[h] = self.find(x);
            
        }
    }
}

*/



/*
DOCS


let mut h = HashMap::new();
let a = 5;
h.insert(a,true);
match h.get(&a){
    Some(v) => println!("{}",v),
    None    => println!("none"),
}


use std::mem;

let mut x = 5;
let mut y = 1;
mem::swap(&mut x,&mut y);


let v = vec![0;2]; // [0,0]

s.chars().nth(i as usize).unwrap();





*/

Measured memory_bytes: 35068
h , w = [int(x) for x in input().strip().split()]
mat = []
for _ in range(h):
    mat.append(input())

dp = [[0 for i in range(w)] for j in range(h)]
dp[0][0] = 1
mod = 10**9+7
for i in range(h):
    for j in range(w):
        if mat[i][j]=='#':
            dp[i][j] = 0
        elif i==0 and j==0:
            pass
        elif j<1 and i>=1:
            dp[i][j] = dp[i-1][j]%mod
        elif i<1 and j>=1:
            dp[i][j] = dp[i][j-1]%mod
        else:
            dp[i][j] = ((dp[i][j-1]%mod)+(dp[i-1][j]%mod))%mod

print(dp[h-1][w-1])


Measured memory_bytes: 44640
import math

def gcd_list(nums):
  gcd = nums[0]
  for i in range(1,len(nums)):
    gcd = math.gcd(gcd,nums[i])
  return gcd

N,X = map(int,input().split())
x = list(map(int,input().split()))

x = [abs(i-X) for i in x]

print(gcd_list(x))

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

const int MOD = (int)1e9+7;

int main(){
	int N,T;
	cin >> N >> T;
	vector<int> A(N);
	for(int i=0;i<N;i++)	cin >> A.at(i);

	int ans=0;
	int mi=A.at(0);
	int dif=0;
	for(int i=1;i<N;i++){
		if(A.at(i)<mi)	mi=A.at(i);
		else if(dif==A.at(i)-mi)	ans++;
		else if(dif<A.at(i)-mi){
			ans=1;
			dif=A.at(i)-mi;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  if (N == 3){
    cout << 2 << ' ' << 5 << ' ' << 63 << endl;
  } else if (N == 4){
    cout << 2 << ' ' << 3 << ' ' << 4 << ' ' << 9 << endl;
  } else {
    vector<int> ans;
    int M = N / 8;
    for (int i = 0; i < M; i++){
      ans.push_back(i * 12 + 2);
      ans.push_back(i * 12 + 3);
      ans.push_back(i * 12 + 4);
      ans.push_back(i * 12 + 6);
      ans.push_back(i * 12 + 8);
      ans.push_back(i * 12 + 9);
      ans.push_back(i * 12 + 10);
      ans.push_back(i * 12 + 12);
    }
    int K = N % 8;
    if (K != 0){
      ans.push_back(M * 12 + 6);
      if (K % 2 == 0){
        ans.push_back(M * 12 + 12);
      }
      if (K >= 3){
        ans.push_back(M * 12 + 2);
        ans.push_back(M * 12 + 4);
      }
      if (K >= 5){
        ans.push_back(M * 12 + 3);
        ans.push_back(M * 12 + 9);
      }
      if (K >= 7){
        ans.push_back(M * 12 + 8);
        ans.push_back(M * 12 + 10);
      }
    }
    for (int i = 0; i < N; i++){
      cout << ans[i];
      if (i < N - 1){
        cout << ' ';
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 3760
#include<iostream>
#include<string>
#include <algorithm>


using namespace std;

int main(){
    int i;
    int dish[5];
    int min=10;
    int temp;
    int sum = 0;
    for(i = 0; i < 5; i++){
        cin >> dish[i];
        temp = dish[i]%10;
        if(temp != 0){
            if(min > temp){
                min = temp;
            }
        }
        if(temp != 0){
            dish[i] = dish[i] - temp + 10;
        }
        sum = sum + dish[i];
    }
    if(min != 10){
        sum = sum + min - 10;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

void solve() {
        int n; cin >> n;
        int wh= n/ 500;
        n%= 500;
        int rm= n/ 5;
        cout << wh* 1000+ rm* 5;
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}




Measured memory_bytes: 256