akhauriyash/Code-Regression huggingface dataset:
def calc_data(data):
    count = 0
    c_0, c_1 = 0, 0
    for i in range(len(data)):
        if data[i] == '0':
            if c_1 > 0:
                count += 2
                c_1 -= 1
            else:
                c_0 += 1
        if data[i] == '1':
            if c_0 > 0:
                count += 2
                c_0 -= 1
            else:
                c_1 += 1
    print(count)

def main():
    data = input()
    calc_data(data)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
using System;
using System.Linq;

class I
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var p = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);

		var dp = new double[n + 1, n + 1];
		dp[0, 0] = 1;
		for (int i = 0; i < n; i++) dp[i + 1, 0] = dp[i, 0] * (1 - p[i]);

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				dp[i + 1, j + 1] = dp[i, j] * p[i] + dp[i, j + 1] * (1 - p[i]);
		Console.WriteLine(Enumerable.Range((n + 1) / 2, (n + 1) / 2).Sum(i => dp[n, i]));
	}
}


Measured memory_bytes: 82656
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int a[222222];
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]-=i+1;
  }
  sort(a,a+n);
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=abs(a[i]-a[n/2]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
X,Y = map(int,input().split())
kame = (Y-2*X)

if kame%2 == 0:
    kame = kame//2
    turu = X-kame
    if X == kame+turu and kame>=0 and turu>=0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 8972
import itertools

def calc_dist(x, y):
	return ((x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2) ** 0.5

n = int(input())
cities = [list(map(int, input().split())) for _ in range(n)]

d = {}

for i in range(n):
	for j in range(n):
		d[(i, j)] = calc_dist(cities[i], cities[j])

ans = 0
cnt = 0
for x in itertools.permutations(range(n)):
	cnt += 1
	for i in range(n - 1):
		ans += calc_dist(cities[x[i + 1]], cities[x[i]])
	#print(x)
print(ans / cnt)


Measured memory_bytes: 40812
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def warshall_floyd(g):
    d = defaultdict(dict)
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v))
    V = set(V)
    for i in V:
        for j in V:
            if i in g and j in g[i]:
                d[i][j] = g[i][j]
            else:
                d[i][j] = sys.maxsize
    for k in g:
        for i in g:
            for j in g:
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]

    return d


@mt
def slv(N, M, ABC):
    g = defaultdict(dict)
    for a, b, c in ABC:
        g[a][b] = c
        g[b][a] = c
    d = warshall_floyd(g)

    ans = 0
    for a, b, c in ABC:
        if d[a][b] < c:
            ans += 1
    return ans


def main():
    N, M = read_int_n()
    ABC = [read_int_n() for _ in range(M)]

    print(slv(N, M, ABC))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6724
#include<stdio.h>

char map[16][16];
int ans;

void func(int x,int y){
	map[x][y] = 0;
	if(map[x][y+1] == '1' && y+1<13)
		func(x,y+1);
	if(map[x][y-1] == '1' && y-1>-1)
		func(x,y-1);
	if(map[x+1][y] == '1' && x+1<13)
		func(x+1,y);
	if(map[x-1][y] == '1' && x-1>-1)
		func(x-1,y);
	
}

int main(void){
	while(scanf("%s",&map[0])!=EOF){
		int i,j;
		for(i = 1; i < 12; i++){
			scanf("%s",&map[i]);
		}
		
		for(i = 0; i < 12; i++){
			for(j = 0; j < 12; j++){
				if(map[i][j] == '1'){
					ans++;
					func(i,j);
				}
			}
		}
		
		printf("%d\n",ans);
		for(i = 0; i < 12; i++){
			for(j = 0; j < 12; j++){
				map[i][j] = 0;
			}
		}
		ans = 0;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void) {
	int a, b, d, r;
	double f;
	scanf("%d %d", &a, &b);
	d = a/b;
	r = a%b;
	f = (double)a/(double)b;
	printf("%d %d %f\n", d, r, f);
	return 0;
}


Measured memory_bytes: 2140
n = int(input())
a = list(map(int, input().split()))

abs_list = []
count = 0
for i in range(n):
   abs_list.append(abs(a[i]))
   if a[i] < 0:
       count += 1

if count%2 == 1:
    print(sum(abs_list) - min(abs_list)*2)
else:
    print (sum(abs_list))


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    string S;
    cin >> S;
    ll N = S.size();

    vector<ll> loc[26];
    REP(i, N) loc[S[i]-'a'].push_back(i);
    REP(i, 26) loc[i].push_back(N);

    vector<ll> dp(N+2, 0);
    dp[N] = 1;
    for(int i=N-1;i>=0;i--){
    	ll mi = (1ll<<60);
    	REP(j, 26){
    		ll pos = lower_bound(loc[j].begin(), loc[j].end(), i) - loc[j].begin();
    		mi = min(mi, dp[loc[j][pos]+1]);
    	}
    	dp[i] = mi+1;
    }
    //cout << dp << endl;

    ll now = 0;
    string res = "";
    while(1){
    	REP(i, 26){
    		ll pos = lower_bound(loc[i].begin(), loc[i].end(), now) - loc[i].begin();
    		ll next = loc[i][pos]+1;
    		if(dp[next] == dp[now]-1){
    			now = next;
    			res += char('a'+i);
    			break;
    		}
    	}
    	if(res.size()==dp[0]) break;
    }
    cout << res << endl;
    return 0;
}

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

int main() 
{
    string s, res;
    cin >> s;
    int x = stoi(s.substr(0,2));
    int y = stoi(s.substr(2,2));
    if (x>=1 && x<=12 && y>=1 && y<=12)
        res = "AMBIGUOUS";
    else if (x>=1 && x<=12 && (y==0 || y>12))
        res = "MMYY";
    else if ((x==0 || x>12) && y>=1 && y<=12)
        res = "YYMM";
    else
        res = "NA";
    cout << res;
    return 0;
}

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

int main(void){
    int n,m,c;
    cin>>n>>m>>c;
    int B[m+1]={0,};
    int A[n+1][m+1]={0,};
    int acc=0, ret=0;
    for(int i=0;i<m;i++){
        cin>>B[i];
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>A[i][j];
        }
    }

    for(int i=0;i<n;i++){
        acc=0;
        for(int j=0;j<m;j++){
            //cout<<"A[i][j]: "<<A[i][j]<<" B: "<<B[j]<<"\n";
            //cout<<"A[i][j]*B[j]: "<<A[i][j]*B[j]<<"\n";
            acc += A[i][j]*B[j];

        }
        //cout<<"acc: "<<acc<<" c:"<<c<<endl;
        if(acc+c > 0)
            ret++;
    }
    cout<<ret<<"\n";

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

public class B{
    public static void Main(){
        int[] nl =  Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
        int n = nl[0]; int l = nl[1];
        int ans = 0;
        //おかしいがn,l小さくてコード思いつかないので
        for (int i = l;i<n+l;i++){
            ans += i;
        }
        if (l*(l+n-1)<0){
            Console.WriteLine(ans);
        }
        else if (l>=0){
                Console.WriteLine(ans-l);
        }
        else{
            Console.WriteLine(ans-n-l+1);
        }
    }
}


Measured memory_bytes: 13268
using System;
using System.Text;

namespace DoubleLinkedList
{
	class Node
	{
		public int value;
		public Node prev, post;

		public Node(int value) {
			this.value = value;
			this.prev = null;
			this.post = null;
		}

		public Node(int value, Node prev, Node post) {
			this.value = value;

			// ?????\?????????????????????????????\?¶??????±???????¨????
			this.prev = prev;
			this.post = post;
		}

		//
		// ??????????????§??????????????????
		//

		public void die() {
			prev.post = post;
			if (post != null)
				post.prev = prev;
		}
		

	}

	class DoublyLinkedList
	{
		Node root;
		Node lastNode;

		public DoublyLinkedList() {
			root = new Node(-1, null, null);
			lastNode = new Node (-1, null, null);

			root.post = lastNode;
			lastNode.prev = root;
		}

		//
		// ?????????????????????????´??????????
		//
		public void insert(int value) {
			Node node = new Node(value);
			node.post = root.post;
			if (root.post != null) {
				root.post.prev = node;
			}
			root.post = node;
			node.prev = root;
		}

		//
		// ??????????????????value???????????????????????????
		//
		public void delete(int value) {

			Node curNode = root.post;
			while (curNode != null) {
				if (curNode.value == -1)
					break;
				if (curNode.value == value) {
					curNode.die ();
					break;
				}
				curNode = curNode.post;
			}

		}

		//
		// ???????????????????????????????????????
		//
		public void deleteFirst() {
			if (root.post == lastNode)
				return;
			root.post.die ();
		}

		//
		// ????????????????°????????´??????????
		//
		public void deleteLast() {
			if (root.post == lastNode)
				return;
			lastNode.prev.die ();
		}

		//
		// ??????
		//
		public void dump() {
			Node curNode = root.post;
			int isf = 0;
			StringBuilder sb = new StringBuilder ();

			while (curNode != null) {
				if (isf++ > 0)
					sb.Append (" ");
				sb.Append (curNode.value.ToString ());
				curNode = curNode.post;
				if (curNode.value == -1)
					break;
			}
			Console.WriteLine (sb);
		}

	}

	class MainClass
	{
		public static void Main (string[] args)
		{
			DoublyLinkedList list = new DoublyLinkedList ();

			int n = int.Parse (Console.ReadLine ());
			for (int i = 0; i < n; ++i) {
				string[] cmd = Console.ReadLine ().Split (' ');
				char[] cmd1 = cmd [0].ToCharArray ();

				// ????????????
				if (cmd1 [0] == 'i') {
					list.insert(int.Parse(cmd[1]));
				} else if (cmd1 [0] == 'd') {
					if (cmd1.Length > 6) {
						if (cmd1 [6] == 'F') {
							list.deleteFirst ();
						} else if (cmd1 [6] == 'L') {
							list.deleteLast ();
						}
					} else {
						list.delete (int.Parse (cmd [1]));
					}
				}

			}

			list.dump ();
		}
	}
}

Measured memory_bytes: 69272
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intinf 1000000000
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int n, T, ans, c, t;

int main() {
	cin >> n >> T;
	ans = intmax;
	rep(n) {
		cin >> c >> t;
		if (t <= T)ans = min(ans, c);
	}
	if (ans == intmax)cout << "TLE" << endl;
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
while True:
    H,W = (int(x) for x in input().split())
    
    if H == 0 and W == 0:
        break
    
    i = 0 
    while i < H:
        j = 0 
        while j < W:
            print ("#", end='')
            j += 1
        print ('')
        i += 1
    print ('')


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

long long int answ(long long int x){
  if(x==1) return 1;
  if(x>1) return 2*answ(x/2)+1;
}
int main() {
    int s,w;
    cin>>s>>w;
    if(w>=s) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <limits.h>
using namespace std;

int main(){
  int n; cin >> n;
  int minx = INT_MAX, sum = 0, x;
  for(int i = 0; i < n; i++){
    cin >> x;
    if(x <= minx){
      minx = x;
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define REP(i, vec) for(auto i = vec.begin(); i != vec.end(); ++i)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, 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; }
template<class T> inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T> inline T LCM(T a, T b) { return (a + (b - 1)) / b; }

int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;

	vi A(a), B(b), C(c);
	rep(i, a) cin >> A[i];
	rep(i, b) cin >> B[i];
	rep(i, c) cin >> C[i];

	sort(DESC(A));
	sort(DESC(B));
	sort(DESC(C));

	priority_queue<int> pq;
	rep(i, x) pq.push(A[i]);
	rep(i, y) pq.push(B[i]);
	rep(i, min(c, x + y)) pq.push(C[i]);

	ll ans = 0;
	rep(i, x + y) {
		ll tmp = pq.top(); pq.pop();
		ans += tmp;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();

		int nC2 = 1;
		for(int i = n; i>n-2; i--){
			nC2 *= i;
		}
		nC2 /= 2;
		if(n < 2){
			nC2 = 0;
		}

		int mC2 = 1;
		for(int i = m; i>m-2; i--){
			mC2 *= i;
		}
		mC2 /= 2;
		if(m < 2){
			mC2 = 0;
		}
		System.out.println(nC2+mC2);

	}


}


Measured memory_bytes: 23764
#include<stdio.h>
#define M 1000000000
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,m,l,min,mi,i,j,k,f[110]={0};
  int a,b,d[110][110],t[110][110],c[110][110]={0};
  while(scanf("%d %d %d",&n,&m,&l),n){
    for(i=0;i<110;i++){
      for(j=0;j<110;j++)d[i][j]=c[i][j]=M;
      f[i]=-1;
    }
    d[0][1]=0;
    while(m--){
      scanf("%d %d %d %d",&a,&b,&i,&j);
      c[b][a]=c[a][b]=i;
      t[b][a]=t[a][b]=j;
    }
    for(i=0;i<=l;i++){
      for(j=1;j<=n;j++){
	min=M;
	for(k=1;k<=n;k++){
	  if(f[k]==i)continue;
	  if(min>d[i][k])min=d[i][mi=k];
	}
	f[mi]=i;
	for(k=1;k<=n;k++){
	  if(c[mi][k]==M)continue;
	  d[i  ][k]=MIN(d[i][k],d[i  ][mi]+t[mi][k]);
	  d[i+1][k]=MIN(d[i][k],d[i+1][k]);
	  if(i+c[mi][k]<=l)d[i+c[mi][k]][k]=MIN(d[i+c[mi][k]][k],d[i][mi]);
	}
      }
    }
    /*for(i=0;i<=l;i++){printf("%2d:",i);
      for(j=0;j<n;j++)printf("%d ",d[i][j+1]);printf("\n");
      }//*/
    printf("%d\n",d[l][n]);
  }
  return 0;
}

Measured memory_bytes: 748
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  VI A(5);
  rep(i,5) cin>>A[i];
  rep(i,5){
    if(A[i]==0){
      cout<<i+1<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] a_str = in.readLine().split(" ");
    int[] a = new int[3];
    a[0] = Integer.parseInt(a_str[0]);
    a[1] = Integer.parseInt(a_str[1]);
    a[2] = Integer.parseInt(a_str[2]);
    int min = Math.min(Math.min(a[0],a[1]),a[2]);
    int sum = a[0] + a[1] + a[2];
    int max = Math.max(Math.max(a[0],a[1]),a[2]);
    System.out.println(max-(sum-min-max) + (sum-min-max)-min);
  }
}


Measured memory_bytes: 21332
def gcd(x, y):
    a, b = max(x, y), min(x, y)
    if b == 0:
        return a
    return gcd(a % b, b)


def lcm(a, b):
    return a*b//gcd(a, b)


A, B = list(map(int, input().split()))
print(lcm(A, B))


Measured memory_bytes: 2940
A, V = map(int, input().split()) # 鬼
B, W = map(int, input().split())
T = int(input())

if A <= B: # 鬼が左側
    A += V*T
    B += W*T
    if A >= B:
        print("YES")
    else:
        print("NO")
else:
    A -= V*T
    B -= W*T
    if A <= B:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 61620
import sys
import heapq as hp

def eval(x, y, c):
    return c + (w - 1 - x + h - 1- y)

h, w = [int(x) for x in input().rstrip().split()]
matrix = [list(input().rstrip()) for _ in range(h)]
open = [[False for _ in range(w)] for _ in range(h)]

x, y, cost = 0, 0, 0
open[y][x] = True
queue = []
hp.heappush(queue, (eval(x, y, 1), x, y, 1))
while [x, y] != [w-2, h-1] and [x, y] != [w-1, h-2]:
    e, x, y, c = hp.heappop(queue)
    for dx, dy in [[1,0], [-1,0], [0,1], [0,-1]]:
        if 0 <= x+dx <= w-1 and 0 <= y+dy <= h-1 and matrix[y+dy][x+dx] == "." and not open[y+dy][x+dx]:
            hp.heappush(queue, (eval(x+dx, y+dy, c+1), x+dx, y+dy, c+1))
            open[y+dy][x+dx] = True
    cost = c+1
    
    if not queue:
        print(-1)
        sys.exit()
print(sum(list(map(lambda x: x.count("."), matrix))) - cost)

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

// ll extended_gcd(ll a, ll b, ll &x, ll &y)
// {
//     if(a==0)
//     {
//         x = 0;
//         y = 1;
//         return b;
//     }
    
//     ll x1,y1;
//     ll g = extended_gcd(b%a, a, x1, y1);
    
//     x = y1-(b/a)*x1;
//     y = x1;
//     return g;
// }

// ll powe(ll x,ll n) {
//   if(x==0) return 0;
//   if(n==0) return 1;
//   ll val = powe(x,n/2);
//   if(n%2) return (((val*val)%N)*x)%N;
//   return (val*val)%N;
// }

// ll comb(ll n, ll k) { 
//     if(k==0) return 1;
//     if(k==n) return 1;
//     return (((mods[n]*invmods[n-k])%N)*invmods[k])%N;
// }

// ll cofac(vector<vector<ll> > &adj) {
//   ll tot = 1, idx;
//   ll res = 1;

//   for(ll i=1;i<adj.size();i++) {
//     idx = i;

//     while(idx<adj.size() && !adj[idx][i])
//       idx++;

//     if(idx==adj.size())
//       return 0;

//     if(idx!=i) {
//       swap(adj[i],adj[idx]);
//       if((idx-i)%2)
//         res = -res;
//     }

//     vector<ll> temp(adj[i].begin(),adj[i].end());

//     ll val = temp[i];
//     for(ll j=i+1;j<adj.size();j++) {
//       ll ids[b] = adj[j][i];

//       for(ll k=i+1;k<adj.size();k++) {
//         adj[j][k] = ((val*adj[j][k])%N - (ids[b]*temp[k])%N + 2*N)%N;
//       }

//       tot = (tot*val)%N;
//     } 
//   }

//   for(ll i=1;i<adj.size();i++)
//     res = (res * adj[i][i])%N;
  
//   ll x,y;
//   extended_gcd(tot,N,x,y);
//   // cout<<(res*x)%N<<endl;
//   return (2*N+(res*x)%N)%N;
// }




int main() {

  int m,d;
  cin>>m>>d;

  // if(d<22 || m<4) {
  //   cout<<0<<endl;
  //   return 0;
  // }

  int c = 0;
  for(int i=1;i<=m;i++) {
    for(int j=1;j<=d;j++) {
      int a = j/10, b=j%10;
      if(a>=2 && b>=2 && a*b==i)
        c++;
    }
  }

  cout<<c<<endl;




  return 0;
} 


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

#define INF 10000000
int main()
{
  int w,h;
  cin>>w>>h;
  int maps[h][w];
  pair<int,int>start;
  pair<int,int>goal;
  vector<pair<int,int> >m;
  memset(maps,0,sizeof(maps));

  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      {
	char tmp;
	cin>>tmp;
	maps[i][j]=max(maps[i][j],1);
	if(tmp=='S')
	    start=make_pair(i,j);
	if(tmp=='G')
	    goal=make_pair(i,j);
	if(tmp=='M')
	  m.push_back(make_pair(i,j));
	if(tmp=='#')
	  {
	    maps[i][j]=INF;
	    for(int ii=i-1;ii<i+2;ii++)
	      for(int jj=j-1;jj<j+2;jj++)
		{
		if(ii>=0 && ii<h &&
		   jj>=0 && jj<w )
		  maps[ii][jj]=max(maps[ii][jj],3);
		}
	    for(int ii=i-2;ii<i+3;ii++)
	      for(int jj=j-2;jj<j+3;jj++)
		if(ii>=0 && ii<h &&
		   jj>=0 && jj<w )
		  maps[ii][jj]=max(maps[ii][jj],2);
	  }
      }
/*
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      {
	if(maps[i][j]==INF)
	  cout<<'#';
	  else
	    cout<<maps[i][j];
	if(j==w-1)
	  cout<<endl;
      }
*/
  //cnt,bit,<pos>;
  priority_queue<pair<pair<int,int> ,pair<int,int> >,vector< pair<pair<int,int> ,pair<int,int> > > ,greater< pair<pair<int,int> ,pair<int,int>  > >  >qu;
  qu.push(make_pair(make_pair(0,0),start));
  int msize=m.size();
  bool closed[h][w][1<<msize];
  memset(closed,false,sizeof(closed));
  int dx[]={1,-1,0,0};
  int dy[]={0,0,1,-1};
  while(!qu.empty())
    {
      int cnt=qu.top().first.first;
      int bit=qu.top().first.second;
      pair<int,int> pos=qu.top().second;
      qu.pop();
      for(int i=0;i<msize;i++)
	{
	  if(pos==m[i])
	    bit|=(1<<i);
	}
      if(pos==goal && bit==(1<<msize)-1)
	{
	  cout<<cnt<<endl;
	  break;
	}
      if(closed[pos.first][pos.second][bit])
	continue;
      closed[pos.first][pos.second][bit]=true;
      for(int i=0;i<4;i++)
	{
	  if(pos.first+dx[i]>=0 && pos.first+dx[i]<h &&
	     pos.second+dy[i]>=0 && pos.second+dy[i]<w  &&
	     !closed[pos.first+dx[i]][pos.second+dy[i]][bit]
	     )
	    qu.push(make_pair(make_pair(cnt+maps[pos.first][pos.second],bit),
			      make_pair(pos.first+dx[i],pos.second+dy[i])));

	}
    }
}

Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
ll modpow(ll n, int k) {
	ll r = 1;
	while (k > 0) {
		if (k&1) (r *= n) %= mod;
		(n *= n) %= mod;
		k >>= 1;
	}
	return r;
}
ll f(int n) {
	return modpow(2, n);
}
int main() {
	int N;
	cin >> N;
	ll res = 1, res0 = 0;
	map<pair<ll,ll>,pair<int,int>> cnt;
	for (int i = 0; i < N; ++ i) {
		ll a, b;
		cin >> a >> b;
		if (b < 0) { a = -a; b = -b; }
		if (a == 0 && b == 0) {
			++ res0;
		} else {
			auto g = abs(gcd(a, b));
			a /= g;
			b /= g;
			if (a <= 0) {
				++ cnt[{b,-a}].second;
			} else {
				++ cnt[{a,b}].first;
			}
		}
	}
	for (auto p : cnt) {
		auto t = f(p.second.first) + f(p.second.second) + mod - 1;
		(res *= t) %= mod;
	}
	res = (res + res0 + mod - 1) % mod;
	cout << res << endl;
}


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

using namespace std;

int s[20],p[20];
int n;

int dfs(int x,int r){
  if(x==n)return 0;
  int m=dfs(x+1,r);
  if(r>=s[x]){
    m=max(m,p[x]+dfs(x+1,r-s[x]));
  }
  return m;
}

int main(){
  int D;
  cin>>D;
  for(int i=0;i<2;i++){
    int x;
    cin>>x;
    while(x--){
      string a;
      int pi;
      cin>>a>>pi;
      if(a==string(i+1,'D')){
	s[n]=i+1;
	p[n++]=pi;
      }
    }
  }
  cout<<dfs(0,D)<<endl;
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstring>
using namespace std;
//const int INF=0x3f3f3f3f,maxn=;
//vector<int>v[maxn];
//map<int,string>mp[maxn];
//queue<int>q[maxn];/
int ac,tle,wa,re,n,m;
int main()
{
	int i,j,k,ans=0;
	long long x,y;
	cin>>n;
	for(i=0;i<n;i++)
	{
		string s;
		cin>>s;
		if(s=="AC")
			ac++;
		if(s=="WA")
			wa++;
		if(s=="TLE")
			tle++;
		if(s=="RE")
			re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
	return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n+2);
    int sum = 0;
    a[0] = 0;
    rep(i, n){
        cin >> a[i+1];
    }
    a[n+1] = 0;

    rep(i, n+2){
        sum += abs(a[i] - a[i+1]);
    }

    for(int i = 1; i <= n; ++i){
        ppp(sum + abs(a[i-1] - a[i+1]) - (abs(a[i-1]-a[i]) + abs(a[i] - a[i+1])));
    }






    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <complex>
#include <vector>
#include <cmath>

const double EPS=1e-10;

#define equals(a, b) (fabs((a)-b(b))<EPS)
#define X real()
#define Y imag()

using namespace std;

typedef complex<double> Point;
typedef complex<double> Vector;

struct Segment {
    Point p1, p2;
};
typedef Segment Line;

struct Circle {
    Point c;
    double r;
    Circle(Point c=Point(), double r=0.0) :
        c(c),r(r){}
};

typedef vector<Point> Polygon;

double dot(Vector a, Vector b) {
    return a.X*b.X + a.Y*b.Y;
}

double cross(Vector a,Vector b) {
    return a.X*b.Y - a.Y*b.X;
}

Point project(Segment s, Point p) {
    Vector base = s.p2-s.p1;
    double r=dot(p-s.p1,base) / norm(base);
    return s.p1+base*r;
}

Point reflect(Segment s, Point p) {
    return p+(project(s,p)-p)*2.0;
}

int main() {
    Segment s;
    {
        double x1,y1;
        double x2,y2;
        cin>>x1>>y1>>x2>>y2;
        s=Segment({Point(x1,y1),Point(x2,y2)});

    }
    int q;
    cin>>q;
    while(q-->0) {
        double x1,y1;
        cin>>x1>>y1;
        Point p=Point(x1,y1);
        Point x=reflect(s,p);
        printf("%.10f %.10f\n",x.X,x.Y);
    }
}

Measured memory_bytes: 1252
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        ArrayList<BigInteger> array = new ArrayList<BigInteger>();
        BigInteger result = BigInteger.valueOf(1);
        BigInteger x = BigInteger.valueOf(1);
        for(int i=0; i<18; i++) x = x.multiply(BigInteger.valueOf(10));
        for(int i=0; i<n; i++){
            BigInteger input = BigInteger.valueOf(sc.nextLong());
            if(input == BigInteger.ZERO){
                out.println(0);
                out.flush();
                return;
            }else{
                array.add(input);
            }
        }

        for(BigInteger num : array){
            result = result.multiply(num);

            if(result.compareTo(x) == 1) {
                out.println("-1");
                out.flush();
                return;
            }
        }

        out.println(result);



        out.flush();

    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 58888
//long long使う！！！！！！
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;

ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}

const ll big=998244353;
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x);
    ll t=exp(x,y/2);
    return (t*t);
}
 
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

typedef pair<int,int> p;



int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(0);
    /*--------------------------------*/
    
    int n;cin >> n;
    map<int,int> a;
    int s;
    rep(i,n){cin >> s;a[s]++;}
             
    int cnt=0;
    if(a.count(1)){if(a[1]==1)cout << 1 << endl;else cout << 0 << endl;return 0;}
    for(p t:a){
        int v=t.first;
        //vの約数列挙、一つでも存在すればcnt++
        if(t.second>1){cnt+=t.second;continue;}
        for(int i=2;i*i<=v;i++){
            if(v%i!=0)continue;
            else{
                if(a.count(i)||a.count(v/i)){cnt++;break;}
            }
        }
    }
    cout << n-cnt << endl;
}

Measured memory_bytes: 12996
#include <iostream>
 
using namespace std;
 
int main()
{
    string a,b;
    int r=0;
    cin>>a>>b;
   
   
   if(a[0]==b[0])
   r++;
   if(a[1]==b[1])
   r++;
   if(a[2]==b[2])
   r++;

   cout<<r;
  
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

#define MAXI 100000

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

//input
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int hotels, maxdist, queries, temp, a, b;
    cin >> hotels;
    ordered_set loc;

    for(int one = 0; one < hotels; one++){
        cin >> temp;
        loc.insert(temp);
    }
    cin >> maxdist >> queries;

    //sparse table
    int temp2 = *loc.find_by_order(hotels-1);
    temp = log2(temp2);
    int st[hotels][temp+1]; //only for hotels that are not the leftmost

    //compute the furthest achievable hotel in 1 day
    for(int one = 0; one < hotels; one++){
        int temp = *loc.find_by_order(one);
        st[one][0] = loc.order_of_key(temp-maxdist);
    }

    //compute furthest hotel achievable in 2^temp days
    for(int one = 1; one < temp+1; one++){
        for(int two = 0; two < hotels; two++){
            st[two][one] = st[ (st[two][one-1]) ][one-1];
        }
    }
    //bug above

    //queries
    for(int one = 0; one < queries; one++){
        cin >> a >> b;
        a--; b--;
        if(a > b){swap(a,b);}
        int finans = 0;
        while(b > a){
            int days = 1, logdays = 0;
            while(st[b][logdays+1] > a){days*=2; logdays++;}
            finans += days;
            b = st[b][logdays];
        }
        cout << finans << endl;
    }
}

Measured memory_bytes: 17280
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long  n,x;
   cin>>n>>x;
   long long ans=0;
   for(int i=0;i<x;i++)
   {
      int a;
      cin>>a;
   	  ans+=a;
   }
   if(ans>=n)
   cout<<"Yes"<<endl;
   else
   cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

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

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int l,r;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> l >> r;
    if (l <= 0 && r >= 0) cout << "Zero";
    else {
        if (l > 0 || (abs(r-l)&1)) cout << "Positive";
        else cout << "Negative";
    }
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int N,a,b;
    scanf("%d",&N);
    if(N == 1){
        printf("Hello World\n");
    }
    if(N == 2){
        scanf("%d%d",&a,&b);
        printf("%d\n",a+b);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

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

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const int MOD = 1e9 + 7;

long long inq(long long a, long long b)
{
    if (b == 0) return 1;
    long long l = inq(a, b / 2);
    if (b % 2) return l * l % MOD * a % MOD;
    return l * l % MOD;
}

long long n0, m0;
long long dp[310][310][310];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n0 >> m0;
    dp[0][1][1] = 1;
    for (int len = 0; len < m0; len++)
    {
        for (int i = 0; i <= n0; i++)
        {
            for (int j = 0; j <= i; j++)
            {
                dp[len + 1][i + 1][j] = (dp[len + 1][i + 1][j] + dp[len][i][j] * (n0 - i)) % MOD;
                dp[len + 1][i][j] = (dp[len + 1][i][j] + dp[len][i][j] * (i - j)) % MOD;
                dp[len + 1][i][i] = (dp[len + 1][i][i] + dp[len][i][j] * j) % MOD;
            }
        }
    }
    cout << dp[m0][n0][n0];
}


Measured memory_bytes: 226816
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

int main(){
  int n,k;
  cin>>n>>k;
  ll vec[n-1];
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  int bitb[n];
  ll a=0,b=0,ma=vec[0];
  ll ans=150000000000;
  for(int bit=0;bit<(1<<n-1);bit++){
    for(int i=0;i<n-1;i++){
      if(bit&(1<<i)){
        bitb[i]=1;
        b++;
      }
      else{
        bitb[i]=0;
      }
    }
    if(b<k-1){
      b=0;
      continue;
    }
    //cout<<bit<<endl;
    b=0;
    for(int i=1;i<n;i++){
      if(bitb[i-1]==1){
        if(ma>=vec[i]){
          a+=ma+1-vec[i];
          b++;
        }
      }
      ma=max(ma,vec[i]);
      if(b==1){
        ma=ma+1;
        b=0;
      }
    }
    ma=vec[0];
    ans=min(ans,a);
    if(ans==a){
      //cout<<bit<<" "<<a<<endl;
    }
    a=0;
  }
  cout<<ans<<endl;
}

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int mod = 1e9+7;

const int nax = 21;
int ALL_ONE = (1<<nax) - 1;

int dp[(1<<nax)][nax];
int n;
int a[nax][nax];

void add_self(int &a, int b){
    a += b;
    if(a >= mod) a -= mod;
}

int recurse(int mask, int id){
    if(mask == ALL_ONE) return 1;
    if(id == n) return 0;

    int &z = dp[mask][id];
    if(~z) return z;

    z = 0;
    int temp = 0;
    for(int i=0; i<n; i++){
        if(a[i][id] && !(mask&(1<<i))){
            add_self(z, recurse(mask|(1<<i), id+1));
        }
    }
    return z;
}

void solve(){
    cin>>n;
    fr(i, n) fr(j, n) cin>>a[i][j];
    ALL_ONE = (1<<n) - 1;

    rep(i, 0, ALL_ONE){
        rep(j, 0, n-1) dp[i][j] = -1;
    }

    cout<<recurse(0, 0)<<endl;
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



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

#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)

typedef long long ll;

int main(){
  int R, G, B, N;
  ll ans = 0;
  cin >> R >> G >> B >> N;
  for(int i = 0; i * R <= N; ++i){
    for(int j = 0; j*G+i*R<=N; ++j){
      if(N >= R*i+G*j && ((N-R*i-G*j)%B == 0)){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int r, g; cin >> r >> g;
    cout << g*2-r << endl;

    return 0;
}

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

int main()
{
    int a, b, c;
    cin >> a;
    cin >> b; 
    cin >> c;

    bool ans = true;
    if (a == 5 and b == 5 and c == 7)
    {
        ans = true;
    }
    else if (a == 5 and b ==7 and c==5)
    {   
        ans=true;
    }
    else if (a == 7 and b == 5 and c == 5)
    {
       ans = true;
    }
    else
    {
      ans = false;
    }

    if (ans)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

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

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            long T = in.nextInt();
            int[] t = new int[N];
            for (int i = 0; i < N; i++) {
                t[i] = in.nextInt();
            }

            long sum = 0;
            for (int i = 1; i < N; i++) {
                sum += t[i] - t[i - 1] >= T ? T : (t[i] - t[i - 1]);
            }
            sum += T;

            System.out.println(sum);
        }
    }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    copy_n(istream_iterator<int>(cin), n, A.begin());

    int ans = 0;
    for (int i = 0; i < n; i++){
        if (A[A[i] - 1] - 1 == i)
            ans++;
    }

    cout << ans / 2 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
using namespace std;

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

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

    cout << m[1];

    for(int i=2; i<n+1; i++)
    {
        cout << " " << m[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5504
#include <iostream>

using namespace std;

int t[105];
int v[105];
double dp[105][105];
int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> t[i];
  for(int i = 0; i < n; i++) cin >> v[i];

  for(int i = 0; i <= n; i++) {
    for(int j = 0; j < 105; j++) {
      dp[i][j] = -1;
      }
    }
  

  dp[0][0] = 0;

  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= v[i]; j++) {
      if(dp[i][j] == -1) continue;
      for(int k = 0; k <= v[i]; k++) {
	if(abs(j - k) > t[i]) continue;
	double a = v[i] - j;
	double b = v[i] - k;
	if(a + b <= t[i]) {
	  double up = (v[i] + j) * a / (double)2;
	  double stay =  (t[i] - a - b) * v[i];
	  double down = (v[i] + k) * b / (double)2;
	  double c = up + stay + down;
	  dp[i+1][k] = max(dp[i+1][k],dp[i][j] + c);
	}
	else {
	  double x = (k - j + t[i]) / (double)2;
	  double y = (j - k + t[i]) / (double)2;
	  double vv = x + j;
	  double up = (j + vv) * x / (double)2;
	  double down = (vv + k) * y / (double)2;
	  double c = up + down;
	  dp[i+1][k] = max(dp[i+1][k],dp[i][j] + c);
	}
      }
    }
  }

  cout << fixed << dp[n][0] << endl;
}





	


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long i, j, dp[100001] = {0}, a[101], n, k;
	cin >> n >> k;
	for(i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	dp[0] = 0;
	for(i = 1; i <= k; i++)
	{
		for(j = 0; j < n; j++)
		{
			if(i - a[j] >= 0)
			{
				dp[i] |= !dp[i - a[j]];
			}
		}
	}
	if(dp[k])
		cout << "First";
	else
		cout << "Second";
	return 0;
}

Measured memory_bytes: 4404
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/rope"
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
#define lambdify(x) [&](auto &&...args){ return x(forward<decltype(args)>(args)...); }
template<typename T, typename U> T &ctmax(T &x, const U &y){ return x = max<T>(x, y); }
template<typename T, typename U> T &ctmin(T &x, const U &y){ return x = min<T>(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	const int mx = 1e5;
	vector<array<int, 2>> val(n); // value, weight
	for(auto i = 0; i < n; ++ i){
		for(auto j = 0; j < 2; ++ j){
			cin >> val[i][j];
		}
	}
	const int h = 10;
	vector<vector<long long>> dp((1 << h) - 1, vector<long long>(mx + 1));
	// dp[u][x]: max value obtainable for node u with weight at most x
	for(auto x = val[0][1]; x <= mx; ++ x){
		dp[0][x] = val[0][0];
	}
	for(auto u = 1; u < min((1 << h) - 1, n); ++ u){
		int p = u - 1 >> 1;
		dp[u] = dp[p];
		for(auto x = mx; x >= val[u][1]; -- x){
			ctmax(dp[u][x], max(dp[p][x - val[u][1]] + val[u][0], dp[u][x - 1]));
		}
	}
	vector<vector<int>> shift(n, vector<int>(15));
	for(auto u = 1; u < n; ++ u){
		shift[u][0] = u;
		for(auto i = 1; i <= 14; ++ i){
			shift[u][i] = (shift[u][i - 1] - 1) >> 1;
		}
	}
	int qq;
	cin >> qq;
	while(qq --){
		int u, x;
		cin >> u >> x, -- u;
		int ch = __lg(u + 1);
		if(ch < h){
			cout << dp[u][x] << "\n";
		}
		else{
			int d = ch - h + 1, p = shift[u][d];
			long long res = 0;
			for(auto mask = 0; mask < 1 << d; ++ mask){
				long long cv = 0, cw = 0;
				for(auto bit = 0; bit < d; ++ bit){
					if(mask & 1 << bit){
						cv += val[shift[u][bit]][0];
						cw += val[shift[u][bit]][1];
					}
				}
				if(cw <= x){
					ctmax(res, dp[p][x - cw] + cv);
				}
			}
			cout << res << "\n";
		}
	}
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

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

using ll=long long;



void solve(){
    int r;
    cin>>r;
    if(r<1200)cout<<"ABC"<<endl;
    else if(r<2800)cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,m;
P d[100010];
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++)cin>>d[i].first>>d[i].second;
    sort(d,d+n);
    ll ans=0;
    for(int i=0;i<n;i++){
	if(m<=0)break;
	ans+=min(m,d[i].second)*d[i].first;
	m-=d[i].second;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1792
#include<stdio.h>

int main() {
	int i, j, k;
	int	n, m, h, w, g, a, b, c, d;
	int f = 0;

	scanf("%d %d %d", &n, &a, &b);

	if (n*a < b) {
		m = n * a;
	}
	else {
		m = b;
	}

	printf("%d",m);


	return 0;
}

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

typedef long long ll;
const int MAX_N = 100030;    // Change as necessary
const ll  MODD = 1000000009; //

int A[MAX_N];

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  ll n; cin >> n;
  ll k = 0;
	int s=0;
	while(k < n){ s++; k += s; }
  
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256