akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

ll a, b;

ll gcd(ll x, ll y) {
    if (y==0) return x;
    return gcd(y, x%y);
}

int main() {
    cin >> a >> b;
    ll g = gcd(a, b);

    ll ans = 1;
    // 素因数分解
    if (g % 2 == 0) {
        ans++;
        while (g % 2 == 0) g /= 2;
    }
    for (ll i=3; i*i<=g; i+=2) {
        if (g % i == 0) {
            ans++;
            while (g % i == 0) g /= i;
        }

        if (g == 1) {
            break;
        }
    }
    if (g != 1) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

#define POS(i,j)((i)*3+(j))

void run(void){
  int c[9];
  int i;
  for(i=0;i<9;i++) scanf("%d",c+i);

  for(i=1;i<3;i++){
    int t=c[POS(i,0)]-c[POS(0,0)];
    int j;
    for(j=1;j<3;j++){
      if(c[POS(i,j)]-c[POS(0,j)]!=t) break;
    }
    if(j<3){
      printf("No\n");
      return;
    }
  }

  for(i=1;i<3;i++){
    int t=c[POS(0,i)]-c[POS(0,0)];
    int j;
    for(j=1;j<3;j++){
      if(c[POS(j,i)]-c[POS(j,0)]!=t) break;
    }
    if(j<3){
      printf("No\n");
      return;
    }
  }
  printf("Yes\n");
  return;
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    L, R, d = map(int, input().split())

    r = R // d
    l = (L - 1) // d
    print(r - l)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
long long mod = 1e9+7;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
//////////////////////////////////

int main() {
    int n; cin >> n;
    double ans = 0.0;
    int t;
    for(int i=0; i<n; i++) {
        cin >> t;
        ans += 1.0 / t;
    }
    printf("%.10lf\n", 1.0 / ans);
    return 0;
}




// EOF


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

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

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

    int q;
    cin >> q;

    while(q-- > 0){
        int k;
        cin >> k;
        cout << lower_bound(a, a+n, k) - a << endl;
    }

    return 0;
}


Measured memory_bytes: 3476
from collections import Counter

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

# count = [0] * (max(a)+1)

c = Counter(a)
ans = 0

for _a in list(set(a)):
    if c[_a]%2 != 0:
        ans += 1

print(ans)


Measured memory_bytes: 20192
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n,m,r;
    cin>>n>>m>>r;
    int mati[r];
    for(int i=0;i<r;i++){
        cin>>mati[i];
        mati[i]--;
    }
    int a,b,c[n][n]={};
    int d;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        if(i!=j) c[i][j]=1e9;
    }
    for(int i=0;i<m;i++){
        cin>>a>>b>>d;
        a--,b--;
        c[a][b] = d;
        c[b][a]=c[a][b];
    }
    for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
    }
    int ans=1e9;
    sort(mati,mati+r);
    while(next_permutation(mati,mati+r)){
        int ret=0;
        for(int i=0;i<r-1;i++){
            ret+=c[mati[i]][mati[i+1]];
        }
        ans=min(ans,ret);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

string s;
int qn;
deque <char> d;
bool rev = false;

int main() { 

  getline(cin, s);

  for (int i = 0; i < sz(s); i++) {
    d.push_back(s[i]);    
  }  

  scanf("%d", &qn);
  while (qn--) {
    int qt;
    scanf("%d", &qt);
    if (qt == 1) {
      rev = !rev;
    } else {
      int f; char c;
      scanf("%d %c\n", &f, &c);
      if (f == 1) {
        if (!rev) {
          d.push_front(c);
        } else {
          d.push_back(c);
        }
      } else {
        if (!rev) {
          d.push_back(c);
        } else {
          d.push_front(c);
        }
      }
    }
  }

  string ans = "";
  while (!d.empty()) {
    ans.append(1, d.front());
    d.pop_front();
  }
  if (rev) {
    reverse(all(ans));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1412
import bisect
A, B, Q = map(int,input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]
S.insert(0,-float("inf"))
S.append(float("inf"))
T.insert(0,-float("inf"))
T.append(float("inf"))
for i in range(Q):
  ans = float("inf")
  #shrine start
  plc_id = bisect.bisect_left(S,X[i])
  right = bisect.bisect_left(T,S[plc_id])
  left = bisect.bisect_left(T,S[plc_id-1])
  one = abs(X[i] - S[plc_id-1])
  two = abs(X[i] - S[plc_id])
  ans = min(ans,one + min(abs(S[plc_id-1] - T[left-1]),abs(S[plc_id-1]-T[left])))
  ans = min(ans,two + min(abs(S[plc_id] - T[right-1]),abs(S[plc_id]-T[right])))
  #temple start
  plc_id = bisect.bisect_left(T,X[i])
  right = bisect.bisect_left(S,T[plc_id])
  left = bisect.bisect_left(S,T[plc_id-1])
  one = abs(X[i] - T[plc_id-1])
  two = abs(X[i] - T[plc_id])
  ans = min(ans,one + min(abs(T[plc_id-1] - S[left-1]),abs(T[plc_id-1]-S[left])))
  ans = min(ans,two + min(abs(T[plc_id] - S[right-1]),abs(T[plc_id]-S[right])))
  print(ans)

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

int main() {
	int N;
	cin >> N;
	
	vector<int> v(N);
	for (auto& i : v) cin >> i;
	sort(v.begin(), v.end());

	while (v[0] != v[N-1]) {
		sort(v.begin(), v.end());
		for (int i = 1; i < N; i++) {
			v[i] = __gcd(v[0], v[i]);
		}
		sort(v.begin(), v.end());
	}

	cout << v[0] << endl;

	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef pair<int ,int > P;
typedef long long ll;

int A,B,C,N,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	for (int i = 0; i < S.size(); ++i)
	{
		if(S[i] == 'A'){
			A = i;
			break;
		}	
	}
	for (int i = 0; i < S.size(); ++i)
	{
		if(S[S.size()-i-1] == 'Z'){
			B = S.size()-i;
			break;
		}
	}
}

void debug(){

}

void answer(){
	cout << B-A << "\n";
}

int main(){
	cin >> S;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 640
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeSet;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static Properties pps = System.getProperties();
	static boolean dbg = true;

	public static void main(String[] args) throws FileNotFoundException {
		// TODO Auto-generated method stub
		// setOut();

		int n=ni();
		int m=ni();
		ns();
		String[] data=new String[m];
		for(int i=0;i<data.length;i++)
			data[i]=ns();
		
		int[] intData=new int[m];
		for(int i=0;i<m;i++)
			intData[i]=ni();
		
		int[] code=new int[m];
		for(int i=0;i<m;i++) {
			String[] strr=data[i].split(" ");
			int k=0;
			for(int j=1;j<strr.length;j++) {
				int bin=Integer.parseInt(strr[j]);
				int number=1<<(bin-1);
				k=k|number;
			}
			code[i]=k;
		}

		int count=0;
		for(int i=0;i<(1<<n);i++) {
			boolean state=true;
			
			for(int j=0;j<code.length;j++) {
				int tmp=code[j]&i;
				if(Integer.bitCount(tmp)%2!=intData[j]) {
					state=false;
					break;
				}
			}
			
			if(state) {
				count++;
			}
		}
		System.out.println(count);
		
	}

	private static void out(String[] strs) {
		// TODO Auto-generated method stub
		for(String str:strs) {
			out(str);
		}
		
	}

	private static void setOut() throws FileNotFoundException {
		sc = new Scanner(new FileInputStream("in.txt"));
		System.setOut(new PrintStream(new FileOutputStream("out.txt")));

	}

	private static void out(List<Integer> l) {
		// TODO Auto-generated method stub
		for (int i : l)
			System.out.println(i);

	}

	private static void out(int[] b) {
		// TODO Auto-generated method stub
		for (int i : b)
			System.out.println(i);

	}

	public static void out(String str) {

		if (dbg)
			System.out.println(str);
	}

	public static void out(int str) {

		if (dbg)
			System.out.println(str);
	}

	public static int ni() {

		return sc.nextInt();

	}

	public static String ns() {

		return sc.nextLine();
	}

	public static int[] ni(int k) {
		int[] res = new int[k];
		for (int i = 0; i < k; i++)
			res[i] = sc.nextInt();
		sc.nextLine();
		return res;
	}

	public static String[] ns(int k) {
		String[] res = new String[k];
		for (int i = 0; i < k; i++)
			res[i] = sc.nextLine();
		return res;
	}

	public static int[][] ni(int a, int b) {
		int[][] res = new int[a][b];
		for (int i = 0; i < a; i++)
			for (int j = 0; j < b; j++)
				res[i][j] = sc.nextInt();
		sc.nextLine();
		return res;
	}
}


Measured memory_bytes: 25172
#include "bits/stdc++.h"
#define MOD 1000000007
using namespace std;
int n;
typedef struct node
{
    long long a[51][51];
    struct node operator *(const struct node & tmp)
    {
	int i,j,k;
	struct node ret;
	memset(ret.a,0,sizeof(ret.a));
	for(k=1;k<=n;k++)
	{
	    for(i=1;i<=n;i++)
	    {
	 	for(j=1;j<=n;j++)
		{
		    if(this->a[i][k]&&tmp.a[k][j])
		    {
			ret.a[i][j]=(ret.a[i][j]+(this->a[i][k]*tmp.a[k][j]))%MOD;
		    }
		}
	    }
	}
	return ret;
    }  
}NODE,*PNODE;
NODE g,ans;
int main()
{
    long long kp,sum=0;
    int flag=0;
    int i,j;
    scanf("%d %lld",&n,&kp);
    for(i=1;i<=n;i++)
    {
	for(j=1;j<=n;j++)
	{
	    scanf("%lld",&g.a[i][j]);
	}
    }
    while(kp)
    {
	if(kp%2)
	{
	    if(!flag)
	    {
		ans=g;
		flag=1;	
	    }
	    else 
	    {
		ans=ans*g;
	    }
	}
	g=g*g;
	kp/=2;
    }
    for(i=1;i<=n;i++)
    {
	for(j=1;j<=n;j++)
	{
	    sum+=ans.a[i][j];
	    sum%=MOD;
	}
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s=="SUN") cout << 7 <<endl;
    else if(s=="MON") cout << 6 << endl;
    else if(s=="TUE") cout << 5 << endl;
    else if(s=="WED") cout << 4 << endl;
    else if(s=="THU") cout << 3 << endl;
    else if(s=="FRI") cout << 2 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var r = decimal.Parse(Console.ReadLine().Trim());
            if (r < 0) break;
            var a = Convert.ToString((int)r, 2);
            var b = ((r - (int)r) * 16);
            var chk = b - (int)b;
            if (a.Length <= 8  && chk ==0)
            {
                var c = Convert.ToString((int)b, 2);
                var zero = new string('0', 8 - a.Length);
                var zero2 = new string('0', 4 - c.Length);
                Console.WriteLine(zero + a + "." +zero2 + c);
            }
            else Console.WriteLine("NA");
        }
    }
}

Measured memory_bytes: 9652
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
int a;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a;
  cout << a*(1+a*(1+a)) << endl;
}

Measured memory_bytes: 3604
#include <iostream>

#define REP(i,n) for(int i=0;i<n;i++)
#define DEBUG 1

using namespace std;

int minusToZero(int a){
	if(a<=0){
		return 0;
	}
	else return a;
}

int overNumToLimit(int a,int limit){
	if(a>=limit){
		return limit;
	}else{
		return a;
	}
}

int main(){


	int n,w,h;
	cin>>n>>w>>h;

	int *flagX;
	int *flagY;
	flagX = new int[2*w+1];
	flagY = new int[2*h+1];

	REP(i,2*w+1){
		flagX[i]=0;
	}
	REP(i,2*h+1){
		flagY[i]=0;
	}

	REP(i,n){
		int tmpX,tmpY,tmpW;
		cin>>tmpX>>tmpY>>tmpW;

		flagX[ minusToZero(2*(tmpX-tmpW)) ]++;
		flagX[ overNumToLimit(2*(tmpX+tmpW)+1, 2*w)]--;

		flagY[ minusToZero(2*(tmpY-tmpW)) ]++;
		flagY[ overNumToLimit(2*(tmpY+tmpW)+1, 2*h)]--;
	}

	int ansFlag=0;
	for(int i=1;i<2*w+1;i++){
		flagX[i]+=flagX[i-1];
	}
	for(int i=1;i<2*h+1;i++){
		flagY[i]+=flagY[i-1];
	}
	REP(i,2*w){
		if(flagX[i]<=0){
			ansFlag++;
			break;
		}
	}
	REP(i,2*h){
		if(flagY[i]<=0){
			ansFlag++;
			break;
		}
	}
	if(ansFlag==2){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}

}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(k);
    map<int, int> mp;
    int i, j, l;
    int cnt = 0;
    for(i = 0; i < k; i++){
        cin >> a.at(i);
        cnt = a.at(i);
        for(j = 0; j < cnt; j++){
            cin >> l;
            mp[l]++;
        }
    }
    int ans = 0; 
    int size = mp.size();
    cout << n-size << endl;
    return 0;
}


Measured memory_bytes: 3608
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)
	dice := scanIntSlice(n)

	psum := 0
	for i := 0; i < k; i++ {
		psum += dice[i] + 1
	}

	max := psum
	for i := k; i < n; i++ {
		psum = psum - (dice[i-k]) + dice[i]
		if psum > max {
			max = psum
		}
	}

	fmt.Printf("%f\n", float64(max)/2)
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

char s[1000010];

bool comp(ii a, ii b){
	return a.ss > b.ss;
}
int32_t main(){
	int n;
	scanf("%d", &n);
	vector<ii> v1, v2;
	for(int z=0; z<n; ++z){
		scanf("%s", s);
		int tam = int(strlen(s));
		int q = 0;
		int a = 0, b = 0;
		for(int i=0; i<tam; ++i){
			if(s[i]=='(') ++q;
			else{
				if(q==0) ++b;
				else --q;
			}
		}
		a = q;
		if(b>=a) v1.push_back(ii(a, b));
		else v2.push_back(ii(a, b));
	}
	sort(all(v1));
	sort(all(v2), comp);
	int r = 0;
	for(auto x:v1){
		int a = x.ff;
		int b = x.ss;
		if(a>r){ 
			printf("No\n");
			return 0;
		}
		r-=a;
		r+=b;
	}
	for(auto x:v2){
		int a = x.ff;
		int b = x.ss;
		if(a>r){ 
			printf("No\n");
			return 0;
		}
		r-=a;
		r+=b;
	}
	if(r==0)
		printf("Yes\n");
	else
		printf("No\n");
}


Measured memory_bytes: 11132
#include<stdio.h>
#include<math.h>

int main() {
	int N;
	double x1, y1, x2, y2, x3, y3;
	double p2, q2, p3, q3, delta;
	double px, py, r;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
		p2 = (x1 + x2) / 2; q2 = (y1 + y2) / 2;
		p3 = (x1 + x3) / 2; q3 = (y1 + y3) / 2;
		delta = (x1 - x2)*(y1 - y3) - (x1 - x3)*(y1 - y2);
		px = ((y1 - y3)*((x1 - x2)*p2 + (y1 - y2)*q2) + (y2 - y1)*((x1 - x3)*p3 + (y1 - y3)*q3)) / delta;
		py = ((x3 - x1)*((x1 - x2)*p2 + (y1 - y2)*q2) + (x1 - x2)*((x1 - x3)*p3 + (y1 - y3)*q3)) / delta;
		r = sqrt((x1 - px)*(x1 - px) + (y1 - py)*(y1 - py));
		printf("%.3lf %.3lf %.3lf\n", px, py, r);
	}


	return 0;
}



Measured memory_bytes: 2028
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#if     DEBUG
#define trace(var)  {cerr << "Line " << __LINE__ << ": " << #var << "=" << var << nl;}
#else
#define trace(var)	{}
#endif
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)
 
typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;typedef vector<vector<int>> vvi;
 
const ll N = 10010;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int m,d; cin >> m >> d;
	int ans = 0;
	for(int i = 22; i <= d; ++i) {
		int tenth = i/10;
		int oneth = i%10;
		if (tenth >= 2 && oneth >= 2) {
			if (tenth*oneth <= m) ans++;
		}
	}
	cout << ans << nl;
	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}

Measured memory_bytes: 256
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int[][] dp = new int[n + 1][3];
        for (int i = 1; i <= n; i++) {
            dp[i][0] = Math.max(dp[i - 1][1], dp[i - 1][2]) + scanner.nextInt();
            dp[i][1] = Math.max(dp[i - 1][0], dp[i - 1][2]) + scanner.nextInt();
            dp[i][2] = Math.max(dp[i - 1][0], dp[i - 1][1]) + scanner.nextInt();
        }
        System.out.println(Math.max(Math.max(dp[n][0], dp[n][1]), dp[n][2]));
    }
}

Measured memory_bytes: 98260
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int>
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a>=c ; a--)
#define UPC(a) (a>='A' && a<='B')
#define LWC(a) (a>='a' && a<='b')

inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void sctd(LL &a,LL &b,LL &c){scanf("%I64d %I64d %I64d",&a,&b,&c);}
inline void scdlld(LL &a,LL &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(LL &a){scanf("%I64d",&a);}

inline void prd(int a){printf("%d",a);};
inline void prdd(int a,int b){printf("%d %d",a,b);};
inline void prtd(int a, int b, int c){printf("%d %d %d",a,b,c);};
inline void prtlld(LL a, LL b, LL c){printf("%I64d %I64d %I64d",a,b,c);};
inline void prdlld(LL a, LL b){printf("%I64d %I64d",a,b);};
inline void prtlld(LL a){printf("%I64d",a);};

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	int n,m;
	scd(n);
	int a[200000],b[200000];
	forin(i,0,n)
	scd(a[i]);
	sort(a,a+n);
	scd(m);
	forin(i,0,m)
	scd(b[i]);
	int d=0;
	forin(i,0,m)
	{
		forin(j,0,n)
		{
			if(b[i]==a[j])
			{
				d++;
				break;
			}
		}		
	}
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 3240
fn read<T: std::str::FromStr>() -> T {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).ok();
	s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().split_whitespace()
		.map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
	(0..n).map(|_| read_vec()).collect()
}

pub trait LexicalPermutation {
	/// Return `true` if the slice was permuted, `false` if it is already
	/// at the last ordered permutation.
	fn next_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T] where T: Ord {
	/// Original author in Rust: Thomas Backman <serenity@exscape.org>
	fn next_permutation(&mut self) -> bool {
		// These cases only have 1 permutation each, so we can't do anything.
		if self.len() < 2 { return false; }

		// Step 1: Identify the longest, rightmost weakly decreasing part of the vector
		let mut i = self.len() - 1;
		while i > 0 && self[i-1] >= self[i] {
			i -= 1;
		}

		// If that is the entire vector, this is the last-ordered permutation.
		if i == 0 {
			return false;
		}

		// Step 2: Find the rightmost element larger than the pivot (i-1)
		let mut j = self.len() - 1;
		while j >= i && self[j] <= self[i-1]  {
			j -= 1;
		}

		// Step 3: Swap that element with the pivot
		self.swap(j, i-1);

		// Step 4: Reverse the (previously) weakly decreasing part
		self[i..].reverse();

		true
	}
}

fn main() {
	let n: usize = read();
	let h: Vec<u64> = read_vec();

	let mut max: u64 = h[0] - 1;
	let mut ok = true;
	for i in 1..n {
		if h[i] > max {
			max = h[i] - 1;
		} else if h[i] < max {
			ok = false;
			break;
		}
	}

	if ok { println!("Yes"); }
	else { println!("No"); }
}


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

using namespace std;

char a[200],b[100];
int main(){
	scanf("%s",&a);
	scanf("%s",&b);
	int l=strlen(a);
	for(int i=0;i<l;i++){
		a[i+l]=a[i];
	}
	for(int i=l;i>0;i--){
		bool f=true;
		for(int j=i;j<i+l;j++){
			if(a[j]!=b[j-i]){
				f=false;
			}
		}
		if(f){
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

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

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}





#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif


struct UnionFind{
        vector<int> par;

        UnionFind(int n): par(n, -1) {}
        void init(int n) { par.assign(n, -1); }

        int root(int x) {
            if (par[x] < 0) return x;
            return par[x] = root(par[x]); // path compression
        }

        bool issame(int a, int b) {
            return root(a) == root(b);
        }

        bool merge(int a, int b) {
            a = root(a); b = root(b);
            if (a == b) return false;

            // merge by size
            if(par[a] > par[b]) swap(a, b);
            par[a] += par[b];
            par[b] = a;
            return true;
        }

        int size(int x) {
            return -par[root(x)];
        }

    };


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll N, M; cin >> N >> M;

    int a[M], b[M];
    REP(i, M) {
        cin >> a[i] >> b[i], --a[i], --b[i];
    }

    UnionFind uf(N);
    ll ans[M];
    ll cur = N * (N - 1) / 2;
    REP(i, M) {
        ans[M-i-1] = cur;

        int ca = a[M-i-1], cb = b[M-i-1];

        if (uf.issame(ca, cb)) continue;

        ll as = uf.size(ca), bs = uf.size(cb);

        cur -= as * bs;

        uf.merge(ca, cb);
    }

    cout << fixed << setprecision(20);
    REP(i, M) cout << ans[i] << endl;

}


Measured memory_bytes: 3328
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    r <- readLn
    g <- readLn
    -- 出力
    putStrLn $ show $ 2*g - r


Measured memory_bytes: 508
// kayseekay :)
#include<bits/stdc++.h>
using namespace std;	
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;	
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		map<int,int>mp;
		for(int i =1;i<=100;i++){
			for(int j =1;j<=100;j++){
				for(int k=1;k<=100;k++){
					int cur = i *i + j*j  +k*k + i*j + k*j + i*k;
					mp[cur]++;
				}
			}
		}
		int n;
		cin >> n;
		fn1{
			cout<< mp[i]<<endl;
		}
	
	
	}
	return 0;
}

Measured memory_bytes: 6064
#include<bits/stdc++.h>
using namespace std;
#define mi INT_MAX
int main()
{int n,i,j,k,p;
 cin>>n>>k;
 int a[n+1],d[n+1];
 for(i=1;i<=n;i++)
 {
   cin>>a[i];
 }
a[0]=a[1];
 d[0]=0;
 d[1]=0;
/*for(j=0;j<=n;j++)
 {
     cout<<a[j]<<" ";
 }*/
 for(j=2;j<=n;j++)
 { d[j]=mi;
   for(p=j-1;p>=j-k&&p>=0;p--)
 { d[j]=min(d[j],abs(a[j]-a[p])+d[p]);
 }
   //d[j]=min(abs(a[j]-a[j-1])+d[j-1],abs(a[j]-a[j-2])+d[j-2]);
  // cout<<d[j]<<endl;

            }
            cout<<d[n]<<endl;
 return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;
const double PI = 3.14159265358979323846;

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double ans;

    if(x<= 0.5*b*a*a){
        ans = 90 - atan(2 * x / b / b / a) * 180 / PI;
    }else{
        ans = 90 - atan(a / (2 * b - 2 * x / a / a)) * 180 / PI;
    }
    cout << fixed << setprecision(6) << ans << endl;

}

Measured memory_bytes: 512
n = gets.chomp!.to_i
xus = Array.new(n)
ans = 0

for i in 0..n-1
	xus[i] = gets.chomp!.split(" ")
	xus[i][0] = xus[i][0].to_f
	if xus[i][1] == "JPY" then
		ans += xus[i][0]
	else
		ans += xus[i][0]*380000
	end
end

puts ans

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

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n);
    vector<int> b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    ll t = 0;
    rep(i, m) t += b[i];

    int j = m;
    int ans = 0;
    rep(i, n+1) {
        while (j > 0 && t > k) {
            --j;
            t -= b[j];
        }
        if (t > k) break;
        ans = max(ans, i+j);
        if (i == n) break;
        t += a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4848
#include <stdio.h>
int main(void){
    int n=0;
    int a[100]={};
    
    int c[8]={};
    int r=0;
    int sc=0;
    
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        
        if(a[i]<400){
            c[0]=1;
        }else if(a[i]<800){
            c[1]=1;
        }else if(a[i]<1200){
            c[2]=1;
        }else if(a[i]<1600){
            c[3]=1;
        }else if(a[i]<2000){
            c[4]=1;
        }else if(a[i]<2400){
            c[5]=1;
        }else if(a[i]<2800){
            c[6]=1;
        }else if(a[i]<3200){
            c[7]=1;
        }else{
            r++;
        }
    }
    
    for(int i=0;i<8;i++){
        sc+=c[i];
    }
    
    
    int min=8;
    int max=0;
    if(sc==0){
        max=r;
        min=1;
    }else{
        max=sc+r;
        min=sc;
    }
    
    printf("%d %d\n",min,max);
}


Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//----------------ここからだよ-------------------

int main(){
    string S; cin>>S;
    string S2;
    S2 = S;
    reverse(all(S2));
    int cnt=0;
    rep(i,S.size()){
        if(S[i]!=S2[i]) cnt++;
    }
    cout<<cnt/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*C++になってるか認したほうがよくない？WOWWOW*/
/*DP使ったほうがよくない？？WOWWOW*/

int main(){
    int a, N; cin>>N;
    vector<int> A(N, 0);
    for(int i=0; i<N-1; i++){
        cin>>a;
        a--;
        A[a]++;
    }
    for(int i=0; i<N; i++){
        cout<<A[i]<<endl;
    }
    return 0;    
}

Measured memory_bytes: 3984
H, W = map(int, input().split())
S = [input() for _ in range(H)]
 
up =    [[0]*(W+2) for _ in range(H+2)]
down =  [[0]*(W+2) for _ in range(H+2)]
left =  [[0]*(W+2) for _ in range(H+2)]
right = [[0]*(W+2) for _ in range(H+2)]
 
for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i-1][j-1] == '.':
            up[i][j] = up[i-1][j] + 1
            left[i][j] = left[i][j-1] + 1
        
        if S[-i][-j] == '.':
            down[-1-i][-1-j] = down[-i][-1-j] + 1
            right[-1-i][-1-j] = right[-1-i][-j] + 1
 
ans = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        ans = max(ans, up[i][j]+down[i][j]+left[i][j]+right[i][j]-3)
print(ans)

Measured memory_bytes: 178564
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::vec::Vec;

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)*}
    };
}

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)*}
    };
}

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")
    };
}

fn main() {
    input!{
        h: usize,
        w: usize,
        a: [chars;h],
    }
    let mut remove_h_idxes = HashSet::new();
    for (i, chars) in a.iter().enumerate() {
        if !chars.contains(&'#') {
            remove_h_idxes.insert(i);
        }
    }
    let mut remove_v_idxes = HashSet::new();
    for j in 0..w {
        remove_v_idxes.insert(j);
        for i in 0..h {
            if a[i][j] == '#' {
                remove_v_idxes.remove(&j);
            }
        }
    }
    let mut new_a = Vec::new();
    for i in 0..h {
        if remove_h_idxes.contains(&i) {
            continue;
        }
        new_a.push(Vec::new());
        for j in 0..w {
            if remove_v_idxes.contains(&j) {
                continue;
            }
            new_a.last_mut().unwrap().push(a[i][j]);
        }
    }
    for line in new_a {
        for ch in line {
            print!("{}", ch);
        }
        println!();
    }
}


Measured memory_bytes: 4352
if __name__ == '__main__':

	n = int(input())
	A = list(map(int,input().split()))

	#元のリストをソート
	A.sort()

	num = 0
	for i in range(n-1):
		if i == 0:
			num = ( A[i] + A[i+1] ) / 2
		else:
			num = ( num + A[i+1]  ) / 2

	print(num)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

ll f(ll n, ll x) {
  return n >= 0 ? n/x+1 : 0;
}

int main() {
  ll a, b, x; cin >> a >> b >> x;
  cout << f(b,x) - f(a-1,x) << endl;
}

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




int main(){
    ll H,W;cin>>H>>W;
    ll c[10][10],w[210][210],ans=0;
    rep(i,0,10)rep(j,0,10)cin>>c[i][j];
    rep(i,0,H)rep(j,0,W)cin>>w[i][j];
    rep(k,0,10)rep(i,0,10)rep(j,0,10)c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
    rep(i,0,H){
        rep(j,0,W){
            if(w[i][j]!=-1)ans+=c[w[i][j]][1];
        }
    }
    cout<<ans<<endl;
}







Measured memory_bytes: 640
a = int(input()) # 500
b = int(input()) # 100
c = int(input()) # 50
x = int(input()) # target amount of money

p = 0 # num of patterns

for i in range(0, a+1):
    for j in range(0, b+1):
        for k in range(0, c+1):
            total = i * 500 + j * 100 + k * 50
            if x == total:
                p += 1

print(p)


Measured memory_bytes: 3060
def size(n)
  (4 << n) - 3
end

def patty(n)
  (2 << n) - 1
end


n, x = gets.split.map(&:to_i)
patties = 0

(n-1).downto(0) do |n|
  if x < 1
    break
  elsif x < size(n) + 1
    x -= 1
  elsif x == size(n) + 1
    x = 0
    patties += patty(n)
  else
    x -= (size(n) + 2)
    patties += patty(n) + 1
  end
end

if x > 0
  patties += 1
end

p patties


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vi a(n),b(n),c(n);
  rep(i,n){
    cin >> a[i];
    a[i]--;
  } 
  rep(i,n) cin >> b[i];
  rep(i,n-1) cin >> c[i];
  int ans = 0;
  rep(i,n){
    ans+=b[a[i]];
    if(i>0)if(a[i] == a[i-1]+1)ans+=c[a[i]-1];
  }
  cout<<ans<<endl;
  return 0;
}

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


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m;
    cin>>n>>m;
    vector<ll> a(m);
    for(int i=0;i<m;++i) cin>>a[i];
    ll sum = accumulate(a.begin(),a.end(),0ll);
    if(sum<=n) cout<<n-sum;
    else cout<<-1;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;

int main(){
	string L; cin >> L;
	int N = L.size();
	long long dp[N][2];
	for(int i=0; i<N; i++){
		if(i==0){
			dp[i][0] = 1;
			dp[i][1] = 2;
		}else{
			if(L[i] == '1'){
				dp[i][0] = (dp[i-1][0] * 3 + dp[i-1][1]) % mod;
				dp[i][1] = (dp[i-1][1] * 2) % mod;
			}else{
				dp[i][0] = (dp[i-1][0] * 3) % mod;
				dp[i][1] = dp[i-1][1];
			}
		}
	}
	cout << (dp[N-1][0] + dp[N-1][1]) % mod << endl;
	return 0;
}

Measured memory_bytes: 2048
//           ––=‹‹BISMILLAHITR RAHMANIR RAHIM››=––
//  Problem name: atcoder bc 179b
//  Lang: C++
//  ©: _Shakib Hossen Shanto   _ CSE Dept__Begum Rokeya University,Rangpur

#include<bits/stdc++.h>
using namespace std;

#define uns unsigned
#define ll long long
#define dl double
#define st string
#define ch char
#define tc ll t;cin>>t;while(t--)


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

    int ara1[n];
    int ara2[n];

    for(int i=0; i<n; i++)
    {
        cin >> ara1[i];
        cin >> ara2[i];
    }

    int count=0,ans=0;

    for(int i=0; i<n; i++)
    {
        if(ara1[i]==ara2[i])
        {
            count++;
            if(count==3) ans++;
        }
        else count=0;
    }

    if(ans>0) cout<<"Yes\n";
    else cout<<"No\n";


   return 0;
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i,n) for(ll i=0; i<(n); i++)
#define forn for(ll i=0; i<(n); i++)
#define fori(i,k,n) for(ll i=k; i<(n); i++) 
#define all(x) (x).begin(),(x).end()
#define en '\n'
#define FILL(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}
template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

const int mxN = 2e5;
// wa somehome

// queue<int> q;
// vector<bool> d(n, 1);
// q.push(0);
// d[0] = 0;
// int ans = 0;
// while(!q.empty()){
// 	bool ok = 1;
// 	int cur = q.front(); q.pop();
// 	for(auto c: adj[cur]){
// 		ok &= h[c] < h[cur];
// 		if(d[c]){
// 			d[c]=0;
// 			q.push(c);
// 		}
// 	}
// 	if(ok) ans++;
// }

void solve(){
	int n, m;
	cin >> n >> m;
	vi h(n);
	for(int i=0; i<n; i++){
		cin >> h[i];
	}
	vvi adj(n);
	while(m--){
		int a, b;
		cin >> a >> b;
		a--; b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	int ans = 0;
	forn{
		bool ok =1;
		for(int c: adj[i]){
			ok &= h[c] < h[i];
		}
		ans += ok;
	}
	// for(int i=0; i<n; i++) {
	// 	if(d[i]) ans++;
	// }
	cout << ans << en;
}

int main(){
	fast;
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
    return 0;
}

Measured memory_bytes: 8724
A, B, M = list(map(int, input().rstrip().split()))
a = list(map(int, input().rstrip().split()))
b = list(map(int, input().rstrip().split()))

cost=[]
for _ in range(M):
    x, y, c = list(map(int, input().rstrip().split()))
    tot = a[x-1] + b[y-1] - c
    cost.append(tot)
    
cost.append(min(a)+min(b))
print(min(cost))


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

using namespace std;
#define ll long long int
#define ull unsigned long long int
#define module 1000000007


int main()
{
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   ll mul;
   ll sum=0;
   for(int i=0;i<n-1;i++)
   {
       for(int j=i+1;j<n;j++)
       {
           mul=a[i]*a[j];
           sum+=mul;
       }
   }
  cout<<sum<<endl;
    return 0;
}

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

int main(){
	int N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++)
    cin>>vec.at(i);
  sort(vec.begin(),vec.end());
  cout<<vec.at(N-1)-vec.at(0)<<endl;
}

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

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

int64_t n, a, b;

void solve() {
    if (a > b || (n < 2 && a != b)) {
        cout << 0 << "\n";
        return;
    }
    int64_t x = (n - 1) * a + b;
    int64_t y = a + (n - 1) * b;
    cout << y - x + 1 << "\n";
}

int main() {
    while(cin >> n >> a >> b) solve();
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int retu[8][3] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {0, 3, 6}, {1, 4, 7}, {2, 5, 8}, {0, 4, 8}, {2, 4, 6}};

int main(){
    string S;
    cin >> S;
    cout << string(S.size(), 'x') << endl;
}


Measured memory_bytes: 256