akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();

        int N = cin.nextInt();
        int[] W = cin.arrayInt();

        int S1 = 0;
        int S2 = 0;
        for (int i = 0; i < N; i++)
        {
            S2 += W[i];
        }

        int min = S2;
        for (int i = 0; i < N; i++)
        {
            S1 += W[i];
            S2 -= W[i];
            int abs = Math.Abs(S2 - S1);
            min = Math.Min(abs, min);
        }
        Console.WriteLine(min);
    }

    long calcDenominator(long K)
    {
        long b = 1;
        while (true)
        {
            b *= 2;
            if (b > K)
            {
                break;
            }
        }
        return b;
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 13140
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K = MI()
    S = ST()
    before = "#"
    RLE = []
    for i,s in enumerate(S):
        if s != before:
            before = s
            RLE.append(1)                        
        else:
            RLE[-1]+=1
    ans = sum(RLE) - len(RLE) #すでに幸せ
    cnt = len(RLE)
    for i in range(K):
        if cnt >= 3:
            ans += 2
        elif  cnt == 2:
            ans += 1
        cnt -=1
        if not cnt:
            break
    print(min(ans,N-1))
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 4476
n,m=gets.split.map &:to_i;
a=gets.split.map &:to_i;
b=gets.split.map &:to_i;
a=a.sort.reverse;
b=b.sort.reverse;
s=1;
ia=ib=0;
(n*m).downto(1){|i|
	d=e=0;
	(d+=1;ia+=1)while ia<n&&a[ia]==i;
	(e+=1;ib+=1)while ib<m&&b[ib]==i;
	s*=(d>1 ? 0 : [ia,1][d])*(e>1 ? 0 : [ib,1][e])-[n*m-i,0][d+e>0 ? 1 : 0];
	s%=10**9+7;
}
p s

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

using namespace std;

int main(){
    string s;
    char a,b;
    int a_cnt=0,b_cnt=0;
    cin>>s;
    a=s[0];
    for(int i=1; i<s.size(); i++){
        if(s[i]!=a){
            b=s[i];
        }
    }
    for(int i=0; i<s.size(); i++){
        if(s[i]==a){
            a_cnt++;
        }
        if(s[i]==b){
            b_cnt++;
        }
    }
    if(a_cnt==2 && b_cnt==2){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    M,D=MI()
    ans=0
    for m in range(1,M+1):
        for d in range(1,D+1):
            d1=d%10
            d2=d//10
            
            if d1>=2 and d2>=2:
                if m==d1*d2:
                    ans+=1
                    
    print(ans)
                

main()


Measured memory_bytes: 38896
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
using namespace std;


int main(void) {

  int n;
  cin >> n;

  for(int i=1; i<=n; i++){
    if( i%3 == 0 || i%10 == 3 || (i%100)/10 == 3 ){
      cout << " " << i;
      continue;
    }
    string s = to_string(i);
    for(int j=0; j<s.size(); j++){
      if( s[j] == '3' ){
        cout << " " << i;
        break;
      }
    }
  }

  cout << endl;

  return 0;
}

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

int main() {
    int N, M;
    int x, y;
    cin >> N >> M;
    vector<int> v(N);
    rep(i, M) {
        cin >> x >> y;
        v.at(x-1) ++;
        v.at(y-1) ++;
    }
    rep(i, N) {
        cout << v.at(i) << endl;
    }
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split_whitespace();
    let n: u64 = iter.next().unwrap().parse().unwrap();
    let m: u64 = iter.next().unwrap().parse().unwrap();
    let d: u64 = iter.next().unwrap().parse().unwrap();
    if d != 0 {
        println!("{}", (2 * (n - d) * (m - 1)) as f64 / ((n * n) as f64));
    } else {
        println!("{}", (m - 1) as f64 / n as f64);
    }
}


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

using namespace std;

long long int dizi[20005],dp[3005][3005],n;

long long int dpf(int sol,int sag){
	if(sol==sag){
		return dizi[sol];
	}
	if(dp[sol][sag]!=-1){
		return dp[sol][sag];
	}
	dp[sol][sag]=max( dizi[sol]+(-dpf(sol+1,sag)), dizi[sag]+(-dpf(sol,sag-1)) );
	return dp[sol][sag];
}
int main(){
	// freopen("a.gir","r",stdin);
	// freopen("a.cik","w",stdout);
	for(int i=0;i<3002;i++){
		for(int j=0;j<3002;j++){
			dp[i][j]=-1;
		}
	}
	scanf("%lld",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&dizi[i]);
	}
	
	printf("%lld\n",dpf(0,(n-1)) );
}

Measured memory_bytes: 70912
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=f; i>(int)t; i--)
#define pb push_back
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rii(x,y) ri(x), ri(y)
#define rll(x,y) rl(x), rl(y)

#define fst first
#define snd second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

const int MAXN = 1e5+5;

int R, C, N;

struct STNode{
	int mx=-1, mn=MAXN*2;
	void merge(STNode& L, STNode& R){
		mx = max(L.mx, R.mx);
		mn = min(L.mn, R.mn);
	}
};
struct ST{
	vector<STNode> T;
	void init(int n){
		T.resize(4*n + 4);
	}

	STNode query(int x,int y,int id = 1,int l = 0,int r = N){
		if(x == l && y == r)	return T[id];
		int M = (l+r)>>1, L=id<<1, R=L|1;
		if(x>=M)	return query(x,y,R,M,r);
		if(y<=M)	return query(x,y,L,l,M);
		STNode res,ln=query(x, M, L, l, M),rn=query(M, y, R, M, r);
		return res.merge(ln, rn), res;
	}

	void update(int p,int x,int id = 1,int l = 0,int r = N){
		if(r - l < 2){
			T[id].mx = max(x, T[id].mx);
			T[id].mn = min(x, T[id].mn);
			return;
		}
		int M = (l+r)>>1, L=id<<1, R=L|1;
		if(p < M) update(p, x, L, l, M);
		else update(p, x, R, M, r);
		T[id].merge(T[L],T[R]);
	}
};



bool border(int r, int c){
	if(r==0 || r==R) return true;
	if(c==0 || c==C) return true;
	return false;
}
int ff(int r, int c){
	if(r==0) return c;
	if(c==C) return c+r;
	if(r==R) return R+C+(C-c);
	return 2*C + R + (R-r);
}

vector<ii> v;
vector<int> cmps;

ST st;

int main(){
	rii(R,C); ri(N);
	FOR(i,0,N){
		int r1, c1, r2, c2;
		rii(r1, c1); rii(r2,c2);
		if(!border(r1,c1) || !border(r2,c2)) continue;
		int a = ff(r1, c1), b = ff(r2, c2);
		cmps.pb(a);
		cmps.pb(b);
		v.pb({a,b});
	}
	sort(cmps.begin(), cmps.end());
	cmps.resize(distance(cmps.begin(), unique(cmps.begin(), cmps.end())));
	FOR(i,0,v.size()){
		v[i].fst = distance(cmps.begin(),lower_bound(cmps.begin(), cmps.end(), v[i].fst));
		v[i].snd = distance(cmps.begin(),lower_bound(cmps.begin(), cmps.end(), v[i].snd));
	}
	N = cmps.size();
	st.init(N);
	bool pos = true;
	FOR(i,0,v.size()){
		int a = v[i].fst, b = v[i].snd;
		if(a>b) swap(a,b);
		STNode q = st.query(a,b+1);
		int mn = q.mn, mx = q.mx;
		if(mn < a || mx > b) pos = false;
		st.update(a,b);
		st.update(b,a);
	}
	if(pos) printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 8300
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

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

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

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

//↑template↑


int main() {



	ll n;
	cin >> n;
	vector<pair<double, pair<ll, ll>>>v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i].second.second >> v[i].second.first;
		v[i].first = v[i].second.first;
	}
	sort(all(v));

	ll time = 0;

	//for (auto i : v) { cout << i.first << endl; }
	for (int i = 0; i < v.size(); ++i) {
		time += v[i].second.second;
		if (time > v[i].second.first) { cout << "No" << endl; return 0; }
	}

	cout << "Yes" << endl;
}




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

int main() {
	int n, m, x; cin >> n >> m >> x;
	vector<int> p(n);
	vector<vector<int>> a(n, vector<int>(m));
	for (int i=0; i<n; i++) {
		cin >> p[i];
		for (int j=0; j<m; j++) {
			cin >> a[i][j];
		}
	}
	
	int mn = INT_MAX;
	for (int i=0; i<(1<<n); i++) {
		int cost = 0;
		vector<int> u(m, 0);
		for (int j=0; j<n; j++) {
			if ((i>>j)&1==1) {
				cost += p[j];
				for (int k=0; k<m; k++) {
					u[k] += a[j][k];
				}
			}
		}
		if (*min_element(u.begin(), u.end()) >= x) {
			mn = min(mn, cost);
		}
	}
	if (mn < INT_MAX) {
		cout << mn;
	}
	else {
		cout << -1;
	}
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << max(0,c-a+b) << endl;
}



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

int main(){
    int R;
    int res;
    // vector<int64_t> vp;
    // int64_t vp[100010];
    // string res;
    // int64_t vp_xor = 0ll;


    cin >> R;
    // for (int i=0; i<N; i++){
    //     cin >> vp[i];
    //     vp_xor ^= vp[i];
    // }

    res = 3 * R * R;
    cout << res << endl;
    return 0;
}


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


int main()
{
int r;
int g;
int b;

cin >> r >> g >> b;

int rgb = r * 100 + g * 10 + b ;
if (rgb % 4 ==0){
  cout << "YES";

}
else{
  cout << "NO";
}

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	double W, H, x, y;
	cin >> W >> H >> x >> y;

	cout << W * H / 2.0 << " ";
	if (W / 2.0 == x && H / 2.0 == y) {
		cout << 1;
	}
	else {
		cout << 0;
	}

	return 0;
}

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

int main(){
    int A, B;
    cin >> A >> B;
    if( A%3==0 || B%3==0 || (A+B)%3==0 ){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }

    return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  if(T.size()-S.size()==1){
    if(T.erase(S.size())==S){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 3624
package main

import(
	"fmt"
	"math"
)

func main() {
	var (
		t,a float64
		n int
	)
	fmt.Scan(&n,&t,&a)
	
	points := make([]float64,n)
	
	mostNearPoint := 0
	var diffavg float64= 1000
	for i := 0; i < n; i++ {
		fmt.Scan(&points[i])
		avgtmp := t - points[i] * 0.006
		if math.Abs(a - avgtmp) < diffavg {
			mostNearPoint = i + 1
			diffavg = math.Abs(a - avgtmp)
		}
	}
	
	fmt.Println(mostNearPoint)
}

Measured memory_bytes: 512
#!/usr/bin/env python
from collections import defaultdict
import math
import re

def main():
    #H, W = map(int, input().split())
    S = list(input().strip())
    d = defaultdict(int)
    for s in S:
        d[s] += 1

    if len(d) == 2 and all([s == 2 for s in d.values()]):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

lli sum[200100];
int main(){

	lli n,m;
	cin>>n>>m;

	REP(i,0,n){
		sum[i+1] += sum[i]+(i+1);
	}

	lli ans = 0;
	REP(i,m,n+1){
		ans += (sum[n]-sum[n-i])-(sum[i-1])+1;
		ans %=MOD;
	}
	ans++;
	ans %= MOD;

	cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 5196
#include <bits/stdc++.h>
#define N 1010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n)	for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
#define elif else if
 
const ll inf = 1e12 + 7;
const lld EPS = 0.00000001;
const ll modw = 1e9 + 7;

using namespace std;

ll dp[N][N];
char c[N][N];

int main()
{
	barnarnar
	int n, m;
	cin >> n >> m;
	forn1(i, n)	forn1(j, m)	cin >> c[i][j];
	dp[1][1] = 1ll;
	forn1(i, n)
		forn1(j, m)
		{
			if(c[i][j] != '#')
			{
				if(c[i - 1][j] != '#')	dp[i][j] += dp[i - 1][j];
				if(c[i][j - 1] != '#')	dp[i][j] += dp[i][j - 1];
				dp[i][j] %= modw;
			}
		}
	cout << dp[n][m];
	return 0;
}



Measured memory_bytes: 9088
using System;

namespace TripleDots
{
    class Program
    {
        static void Main(string[] args)
        {
            const string LastChar = "...";

            string K = Console.ReadLine();
            string S = Console.ReadLine();
            string outChar;

            int int_K = int.Parse(K);

            if (S.Length > int_K)
            {
                outChar = S.Substring(0, int_K) + LastChar;

            } else
            {
                outChar = S;

            }
            Console.WriteLine(outChar);
        }
    }
}


Measured memory_bytes: 27492
#include "bits/stdc++.h"
using namespace std;

int N, M;

void dump(int max_, int min_) {
  cout << "max:" << max_ << " min:" << min_ << endl;
}

int main(int argc, char **argv) {
  int i;

  cin >> N >> M;
  int L[M], R[M];
  int min_ = 0, max_ = N;

  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i];
    if (min_ < L[i])
      min_ = L[i];
    if (max_ > R[i])
      max_ = R[i];
  }

  int ans;
  if (max_ - min_ < 0)
    ans = 0;
  else
    ans = max_ - min_ + 1;

  // dump(max_, min_);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;
    
    int matched = 0;
    for (int d = a; d <= b; ++d)
    {
        if (c % d == 0)
            ++matched;
    }
    
    std::cout << matched << std::endl;
    
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vector<string> vec(2500*5001);

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

    string s;
    int K;
    cin >> s;
    cin >> K;

    // auto compare = [](string& x, string& y) { return x > y; };
    // priority_queue<string, vector<string>, decltype(compare)> pque{compare};
    int total = 0;
    for (int k = 1; k <= K; ++k)
    {
        rep (pos, s.size() - k + 1)
        {
            // pque.push(s.substr(pos, k));
            vec[total++] = s.substr(pos, k);
        }
    }

    sort(vec.begin(), vec.begin() + total);
    vec.erase(unique(vec.begin(), vec.begin() + total), vec.begin() + total);
    cout << vec[K - 1] << "\n";

    // string ans = "";
    // int count = 0;
    // while (!pque.empty())
    // {
    //     if (ans != pque.top())
    //     {
    //         ans = pque.top();
    //         ++count;
    //     }
    //     if (count == K) break;
    //     pque.pop();
    // }

    // cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 99072
#include <stdio.h>

int main()
{
	int a,b;
	char op;
	
	while(1){
		scanf("%d %c %d",&a,&op,&b);
	
		if(op=='?') break;
		if(op=='+') printf("%d\n",a+b);
		if(op=='-') printf("%d\n",a-b);
		if(op=='*') printf("%d\n",a*b);
		if(op=='/') printf("%d\n",a/b);
	}
	
	return 0;
}
	

Measured memory_bytes: 600
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{a:[chars;3]};
    println!("{}", if a[0][a[0].len()-1] == a[1][0] && a[1][a[1].len()-1] == a[2][0] {"YES"} else {"NO"});
}


Measured memory_bytes: 4352
N = int(input())
ans = 0
S = []
for _ in range(N):
    s = int(input())
    ans += s
    if s % 10 != 0:
        S.append(s)

S.sort()

if len(S) > 0 and ans % 10 == 0:
    ans -= S[0]

print(ans if ans % 10 != 0 else 0)


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define pb push_back
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;



int main(){
    int n,k;
    cin>>n>>k;
    cout<<n-k+1<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int a[3][3];

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++){
            std::cin >> a[i][j];
        }
    }
    
    int size, h;
    std::cin >> size;
    for (int g = 0; g < size; g++) {
        std::cin >> h;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++){
                if (h == a[i][j]) {
                    a[i][j] = 0;
                } 
            }
        }
    }

    int temp;
    bool ans = false;
    for (int i = 0; i < 3; i++) {
        temp = 0;
        for (int j = 0; j < 3; j++){
            temp = temp + a[i][j];
        }
        if (temp == 0) {
            ans = true;
        }
    }
    for (int i = 0; i < 3; i++) {
        temp = 0;
        for (int j = 0; j < 3; j++){
            temp = temp + a[j][i];
        }
        if (temp == 0) {
            ans = true;
        }
    }
    if (a[0][0] + a[1][1] + a[2][2] == 0){
        ans = true;
    }
    if (a[0][2] + a[1][1] + a[2][0] == 0){
        ans = true;
    }

    if (ans) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=[input() for i in range(n)]
a=0
b=0
c=0 
d=0
for ss in s:
  if ss=='AC':
    a+=1
  elif ss=='WA':
    b+=1
  elif ss=='TLE':
    c+=1
  elif ss=='RE':
    d+=1
print('AC','x',a)
print('WA','x',b)
print('TLE','x',c)
print('RE','x',d)

Measured memory_bytes: 16328
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int V = Integer.parseInt(sc.next());
        int E = Integer.parseInt(sc.next());
        
        Map<Integer, List<Integer>> graph = new HashMap<>();
        for(int i = 0; i < V; i++){
            graph.put(i, new ArrayList<>());
        }
        int[] indeg = new int[V];
        for(int i = 0; i < E; i++){
            int s = Integer.parseInt(sc.next());
            int t = Integer.parseInt(sc.next());
            graph.get(s).add(t);
            indeg[t]++;
        }
        
        List<Integer> list = new ArrayList<>();
        ArrayDeque<Integer> queue = new ArrayDeque<>();
        for(int i = 0; i < V; i++){
            if(indeg[i] == 0) queue.add(i);
        }
        while(!queue.isEmpty()){
            int u = queue.poll();
            list.add(u);
            for (Integer v : graph.get(u)) {
                indeg[v]--;
                if(indeg[v] == 0) queue.add(v);
            }
        }
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < V; i++){
            sb.append(list.get(i)).append(System.lineSeparator());
        }
        System.out.print(sb);
    }
}


Measured memory_bytes: 73112
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
  dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 20500
#include<stdio.h>
int main(void){
  int cu,cd,input,t,last,i,g,j;
  
  scanf("%d",&g);
  for(j=0;j<g;j++){
    scanf("%d",&t);
    cu=cd=last=0;
    scanf("%d",&last);
    for(i=0;i<t-1;i++){
      scanf("%d",&input);
      if(last-input<0)
      if(input-last>=cu)cu=input-last;
      if(last-input>=cd)cd=last-input;
      last=input;
    }
    if(last==cu)  printf("%d %d\n",0,cd);
    else    printf("%d %d\n",cu,cd);
  }   
  return 0;
}

Measured memory_bytes: 596
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))

mod = 10**9 + 7

dp = [[0 for j in range(m+1)] for i in range(n+1)]

dp[0][0] = 1
for i in range(n+1):
    dp[i][0] = 1
for j in range(m+1):
    dp[0][j] = 1

for i in range(n):
    for j in range(m):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1] - dp[i][j] + dp[i][j]
        else:
            dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1] - dp[i][j]
        dp[i+1][j+1] %= mod

print(dp[n][m])

Measured memory_bytes: 74716
can_buy = []

for n in range(101):
    for d in range(15):
        remnant = n-7*d
        if remnant >= 0 and remnant % 4 == 0:
            can_buy.append(n)
            break

n = int(input())

if n in can_buy:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>

using namespace std;

int main(){
    string s; cin >> s;
    vector<int> v;
    for(int i=0;i<s.size();i++){
        v.push_back(s[i]-'0');
    }
    for(int bit = 0; bit < 8; bit++){
        string tmp = "";
        tmp += (char)(v[0] + '0');
        int sum = v[0];
        // 1 -> +
        // 0 -> -
        for(int i = 0; i<3;i++){
            if(1 << i & bit) {
                sum += v[i+1];
                tmp += '+';
                tmp += (char)(v[i+1] + '0');
            } else {
                sum -= v[i+1];
                tmp += '-';
                tmp += (char)(v[i+1] + '0');
            }
        }
        if(sum == 7){
            tmp += "=7";
            cout << tmp << endl;
            return 0;
        }
    }
}


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

int main () {
  int a , b , c , d ;
  cin >> a >> b >> c >> d ;
  if ( a + b == c + d ){
    cout << "Balanced" << endl ;
  } else if ( a + b > c + d ){
    cout << "Left" << endl ;
  } else {
    cout << "Right" << endl ;
  }
}


Measured memory_bytes: 256
import bisect as bc
 
N = int(input())
A = list(map(int,input().split()))
A.sort()
 
dp = [True for _ in range(A[-1]+1)]
 
for i in range(N):
    ai = A[i]
    for j in range(2,A[-1]+1):
        if ai*j > A[-1]:
            break
        dp[ai*j] = False
 
ans = 0
for i in range(N):
    if dp[A[i]]:
        if bc.bisect_right(A,A[i]) - bc.bisect_left(A,A[i]) == 1:
            ans += 1
 
print(ans)

Measured memory_bytes: 157664
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

void Matrix(int *p, int length){
	int i, j, k, l, q;
	int **m;
	m = (int **)malloc(sizeof(int)*length);
	for (i = 0; i < length; i++)m[i] = (int *)malloc(sizeof(int)*length);

	for (i = 1; i < length; i++) m[i][i] = 0;

	for (l = 2; l < length; l++){
		for (i = 1; i < length - l + 1; i++){
			j = i + l - 1;
			m[i][j] = INT_MAX;
			for (k = i; k <= j - 1; k++){
				q = m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];
				m[i][j] = (m[i][j]<q ? m[i][j] : q);
			}
		}
	}
	printf("%d\n", m[i][j]);
}

main(){
	int i, n, *A;

	scanf("%d", &n);

	A = malloc(sizeof(int)*(n + 2));

	for (i = 1; i<n; i++) scanf("%d%d", &A[i], &A[i+1]);
	scanf("%d%d", &A[i], &A[i + 1]);

	Matrix(A, n + 2);

	return 0;
}

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

int main(){
	int N;
	int A[210];
	cin >> N;
	for(int i=0; i<N; i++) cin >> A[i] ;
	int res = 0;
    while(true){
    	bool exist_odd = false;
    	for(int i=0; i<N;i++){
    		if(A[i] %2 != 0) exist_odd = true;
    	}
    	if(exist_odd) break;

    	for(int i=0; i<N; i++) A[i] /= 2; 
    		++res;
    }

    cout << res << endl;


} 



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
// string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>n;
  ll a[n];
  std::map<ll, ll> mp;
  for (ll i = 0; i < n; ++i)
  {
  cin>>a[i];
  mp[a[i]]++;
  }
  if(mp.size()==1 and mp.count(0)>0)
  {
     c("Yes");
      return;     
  }
  if(mp.size()==2)
  {
     auto it = mp.begin();
     auto xt = it;
     xt++;     
      if(it->first ==0 and (it->second == 2*(xt->second) or xt->second == 2*(it->second) ) )
          {
           c("Yes");
            return; 
          }
  }
  if(mp.size()==3)
  {
    auto  it = mp.begin();
    x = it->second;
    c = it->first;
    it++;

    for(it;it!=mp.end();it++)
    {
      c^= (it->F);
      if(it->second==x)
        y++;
    }
    if(y==2 and c==0)
    {
       c("Yes");
      return;  
    }
  }
   c("No");
      return;
}

signed main(){

      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 5760
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
int dp[2100][2100],a[2100],b[2100],c1[2100][2100],c2[2100][2100];
int main(){
	  int n,m,i,j,k,x;
	  char ch;
	  scanf("%d",&n);
	  for(i=1;i<=2*n;i++){
	  	 cin>>ch;scanf("%d",&x);
	  	 if(ch=='B'){
	  	 	a[x]=i;
	  	 }else {
	  	 	b[x]=i;
	  	 }
	  }
	  for(i=1;i<=n;i++){
	  	 for(j=1;j<i;j++)
	  	    if(a[i]<a[j])c1[i][0]++;
	  	 for(j=1;j<=n;j++){
	  	 	c1[i][j]=c1[i][j-1];
	  	 	if(b[j]>a[i])c1[i][j]++;
	  	 }
	  }
	  for(i=1;i<=n;i++){
	  	 for(j=1;j<i;j++)
	  	    if(b[i]<b[j])c2[0][i]++;
	  	 for(j=1;j<=n;j++){
	  	 	c2[j][i]=c2[j-1][i];
	  	 	if(a[j]>b[i])c2[j][i]++;
	  	 }
	  }
	  int wh1=0,wh2=0;
	  for(i=1;i<=n;i++){
	  	 wh1+=c1[i][0];
	  	 wh2+=c2[0][i];
	  	 dp[i][0]=wh1;
	  	 dp[0][i]=wh2;
	  }
	  for(i=1;i<=n;i++)
	     for(j=1;j<=n;j++)
	        dp[i][j]=min(dp[i-1][j]+c1[i][j],dp[i][j-1]+c2[i][j]);
	  cout<<dp[n][n]<<endl;
	  return 0;
}

Measured memory_bytes: 51456
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	string s,t;
	cin>>s;
	cin>>t;
	reverse(s.begin(),s.end());  
	if(s==t)
		puts("YES");
	else 
		puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

string map[1000];

int DP[1000][1000];

int main(){
	
	int H, W;
	
	while(true){
		
		cin >> H >> W;
		
		if(H == 0 && W == 0){
			break;
		}
		
		for(int i = 0; i < H; i++){
			cin >> map[i];
		}
		
		int ans = 0;
		
		int count = 0;
		
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(map[i][j] == '.'){
					count++;
				}else{
					count = 0;
				}
				DP[i][j] = count;
				if(DP[i][j] > ans){
					ans = DP[i][j];
				}
				//cout << DP[i][j] << " ";
			}
			//cout << endl;
			count = 0;
		}
		//cout << endl;
		
		for(int i = 1; i < H; i++){
			for(int j = 0; j < H - i; j++){
				for(int k = 0; k < W; k++){
					DP[j][k] = min(DP[j][k], DP[j + 1][k]);
					if(DP[j][k] * (i + 1) > ans){
						ans = DP[j][k] * (i + 1);
					}
					//cout << DP[j][k] << " ";
				}
				//cout << endl;
			}
			//cout << endl;
		}
		
		cout << ans << endl;
	}
	return 0;
}

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

void main()
{
    auto N = readln.chomp.to!int;
    long[] as = [0];
    foreach (i, a; readln.split.to!(long[])) as ~= a + as[i];

    auto pq = new int[](N+1);
    auto rs = new int[](N+1);

    int i = 2, j = 1;
    while (i <= N) {
        while (j+1 < i && abs(as[j]*2 - as[i]) > abs(as[j+1]*2 - as[i])) ++j;
        pq[i++] = j;
    }
    i = N-2, j = N-1;
    while (i >= 0) {
        while (j-1 > i && abs(as[j]*2 - as[i] - as[N]) > abs(as[j-1]*2 - as[i] - as[N])) --j;
        rs[i--] = j;
    }

    long r = long.max;
    foreach (k; 2..N-1) {
        i = pq[k];
        j = rs[k];
        r = min(r, max(as[i], as[k]-as[i], as[j]-as[k], as[N]-as[j]) - min(as[i], as[k]-as[i], as[j]-as[k], as[N]-as[j]));
    }
    writeln(r);
}

Measured memory_bytes: 11656
#include<iostream>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
int a[3];
int ans[3]={15000,15000,15000};
cin>>a[0]>>a[1]>>a[2];
sort(a,a+3);
int j=a[2]-a[0];
int k=a[2]-a[1];
if(a[0]%2==a[1]%2)
ans[0]=k+(j-k)/2;
else
if(a[0]%2==a[2]%2)
ans[1]=(k+1)/2+j/2+1;
else
ans[2]=(j+1)/2+k/2+1;
cout<<min(ans[0],min(ans[1],ans[2]));
system("pause");
return 0;
}

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

int main() {
    int64_t n;
    cin >> n;
    int64_t tv = 1, av = 1;
    for (int i = 0; i < n; i++) {
        int64_t t, a;
        cin >> t >> a;
        int64_t p = max((tv+t-1) / t, (av+a-1) / a);
        tv = t * p, av = a * p;
    }
    cout << tv + av << endl;
}


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

using namespace std;

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	int i,flag=0;
	for (i=1;i<=10000;i++)
	{
		if (((a*i)%b)==(c%b))
		{
			cout << "YES";
			flag = 1;
			break;	
		}
	}
	if (!flag)
		cout << "NO";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MAX(a, b, c) max(max(a, b), c)
using namespace std;

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main(){
  int n,m;
  cin >> n >> m;
  UnionFind tr(n);
  REP(i,m){
    int x,y,z;
    cin >> x >> y >> z;
    tr.unite(x-1,y-1);
  }
  set<int> st;
  REP(i,n){
    st.insert(tr.root(i));
  }
  
  cout << st.size() << '\n';
  return 0;
 
}

Measured memory_bytes: 5376
n = int(input())
pnts = [tuple(map(int, input().split())) for i in range(n)]

mxsum = max(map(lambda p: p[0]+p[1], pnts))
mnsum = min(map(lambda p: p[0]+p[1], pnts))
mxdif = max(map(lambda p: p[0]-p[1], pnts))
mndif = min(map(lambda p: p[0]-p[1], pnts))

print(max([mxsum - mnsum, mxdif-mndif]))


Measured memory_bytes: 36032
# -*- coding: utf-8 -*-

## INPUT ###
N, M = map(int, input().split())
tmp = []
k_i = []
p = []

for i in range(M):
    tmp = map(int, input().split())
    k_i.append(list(tmp))
p = list(map(int, input().split()))

det=[]
success = 0

for i in range(2**N):
    sw_status = format(i,'b').zfill(N)
    sw_status = list(map(int, sw_status))
    det=[]
    for k in range(M):
        det_j =0
        for j in range(k_i[k][0]):
            det_j += sw_status[k_i[k][j+1]-1]
        if p[k] == det_j % 2:
            det.append(1)
        else:
            det.append(0)
    if sum(det) == M:
        success += 1
print(success)
            




    
    




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

long long gcd(long long a, long long b);

int main() {
	long long a, b, res;
	while (cin >> a >> b) {
		res = gcd(a,b);
		cout << res << " " << (a*b)/res << endl;
	}
	return 0;
}

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

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int  INF= 1e9+5;
int main(){
	fastio();

 	int n;cin>>n;
 	
    int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    vector<int> dp(n);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
  	dp[2]=abs(h[2]-h[0]);
  
    for(int i=3;i<n;i++){
    	dp[i]=min(   dp[i-1]+abs(h[i]-h[i-1])   ,  dp[i-2]+abs(h[i]-h[i-2]) );
    	


    }
    cout<<dp[n-1]<<endl;





    return 0;

}
	

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iomanip>

using namespace std;

int n, a;
double m, u;

int main () {
    cin >> n;
    for ( int i = 1; i <= n; i++) {
        cin >> a;
        u = (double) 1 / a;
        //cout << u << endl;
        m = double(m + u);
    }
    cout << setprecision(9) << fixed  << 1 / m << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
#define MAX 500000
typedef struct pp{
    int num;
    struct pp *right, *left, *parent;
}PO;
PO *root, *nothing;
int n,input, anum = 0, fnum;
char command[7];
int finder[MAX];

void ins(int n)
{
    PO *x = root;
    PO *y = nothing;
    PO *v;//what i want to put as x;
    v = (PO *)malloc(sizeof(PO));
    v->num = n;
    v->left = nothing;
    v->right = nothing;
    while(1)
    {
        if(x == nothing) break;
        y = x;
        if(v->num < x->num) x = x->left;
        else x = x->right;
    }
    v->parent = y;
    if(y == nothing) root = v;
    else
    {
        if(v->num < y->num) y->left = v;
        else y->right = v;
    }
}

void no2find(PO *r)
{
    if(r == nothing) return;
    if(r->num == input)
    {
        fnum =1;
        return;
    }
    if(input>=r->num) no2find(r->right);
    else no2find(r->left);
}

int find(PO *r)
{
    fnum =0;
    no2find(r);//get datas
    return fnum;
}

void ino(PO *r)
{
    if(r == nothing) return;
    ino(r->left);
    printf(" %d", r->num);
    ino(r->right);
}

void pre(PO *r)
{
    if(r == nothing) return;
    printf(" %d", r->num);
    pre(r->left);
    pre(r->right);
}

int main()
{
    scanf("%d", &n);
    for(int i=0; i<n; i++)
    {
        scanf("%s", command);
        if(command[0] == 'i')
        {
            scanf("%d", &input);
            ins(input);
            anum++;
        }
        else if(command[0] == 'p')
        {
            ino(root);
            printf("\n");
            pre(root);
            printf("\n");
        }
        else
        {
            scanf("%d", &input);
            if(find(root) == 0) printf("no\n");
            else printf("yes\n");
        }
    }
    return 0;
}



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

const int N = 100010;

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

    vector<int> prime(N, 1);
    prime[0] = 0;
    prime[1] = 0;
    for(int i = 2; i <= (int)sqrt(N); i++){
        if(prime[i] == 1){
            for(int j = i + i; j < N; j += i){
                prime[j] = 0;
            }
        }
    }

    vector<int> B(N, 0);
    for(int i = 3; i < N; i += 2){
        if(prime[i] == 1 and prime[(i + 1) / 2] == 1){
            B[i]++;
        }
    }

    for(int i = 3; i < N; i++){
        B[i] += B[i - 1]; 
    }

    int q;
    cin >> q;
    while(q--){
        int l, r;
        cin >> l >> r;
        cout << B[r] - B[l - 1] << endl;
    }

    return 0;
}

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

#define int long long
//typedef long long ll;
#define double long double
#define vec vector
#define pb push_back
#define unset unordered_set
#define ii pair<int, int>
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
typedef vector<int> vi;
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first,l.second+r.second};
} 
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e6 + 3;
const double EPS = static_cast<double>(1e-9);
#define min(a, b) (((a)<(b))?(a):(b))
#define max(a, b) (((a)>(b))?(a):(b))

//************************************
#undef int
int main() {
#define int long long
	ios_base::sync_with_stdio(false); cin.tie();
	//auto beginProgram = chrono::steady_clock::now();
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);

	int a, b, t; cin >> a >> b >> t;
	cout << (int)ceil(t/a)*b << endl;
	
  //auto endProgram = chrono::steady_clock::now();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;
using P = pair<ll, ll>;

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 dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

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

  int n, k;
  cin >> n >> k;
  int r, s, p;
  cin >> r >> s >> p;
  string t;
  cin >> t;

  ll ans = 0;
  rep(i, n) {
    if (i >= k && t[i-k] == t[i]) {
      t[i] = '*';
      continue;
    }
    if (t[i] == 'r') ans += p;
    else if (t[i] == 's') ans += r;
    else if (t[i ]== 'p') ans += s;
  }

  cout << ans << endl;

  return 0;
}


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

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int N; cin >> N;
  long double ans = 0.0;
  for (int i = 0; i < N; i++) {
    long double a; string s; cin >> a >> s;
    if (s == "JPY") {
      ans += a;
    } else {
      ans += (a * 380000.0);
    }
  }

  cout << setprecision(15) << ans << endl;
}


Measured memory_bytes: 256