akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;


int n, m, a, b, c;
string s, t;

int main() {
	cin >> n >> m;
	int cnt = 0;
	for (int i = 1; i <= m; i++)
	{
		int ue = i / 10;
		int sita = i % 10;
		if (ue < 2 || sita < 2)continue;
		if (ue*sita > n)continue;
		cnt++;
	}
	cout << cnt << endl;
}

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

using namespace std;
typedef vector<int> vi;
typedef map<vi, int> ma;

vi a,b;
int N;

ma bfs(vi vec){
    ma tem;
    queue<vi>que;
    que.push(vec);
    tem[vec]=0;
    while(!que.empty()){
        
        vi v=que.front();
        que.pop();
//        cout<<"tem[v]: "<<tem[v]<<endl;
//        for(int i=0;i<v.size();i++)
//            cout<<v[i]<<" ";
//        cout<<endl;
        if(tem[v]>=(N-1)/2)
            continue;
        for(int i=0;i<N;i++)
            for(int j=i+2;j<=N;j++){
                vi n=v;
                reverse(n.begin()+i,n.begin()+j);
                if(tem.find(n)==tem.end()){
                    tem[n]=tem[v]+1;
                    que.push(n);
                }
            }
    }
    return tem;
}

void solve(){
    ma m_a=bfs(a);
    ma m_b=bfs(b);
   
    if(m_a.find(b)!=m_a.end()){
        cout<<m_a[b]<<endl;
        return;
    }
    int ans=N-1;
    do{
        if(m_a.find(b)==m_a.end()||m_b.find(b)==m_b.end())
            continue;
        else
            ans=min(m_a[b]+m_b[b],ans);
    }while(next_permutation(b.begin(), b.end()));
    cout<<ans<<endl;
}

int main(){
    cin>>N;
    for(int i=0;i<N;i++){
        int t;
        cin>>t;
        a.push_back(t);
    }
    b=a;
    sort(b.begin(),b.end());
    solve();
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 2e5+5;

const ll MOD = 1000000007LL;

void solve() {

}

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

    int n;
    cin >> n;
    vector<ll> a(n+1);
    ll first = 0LL;

    for (int i=1; i<=n; i++) {
        cin >> a[i];
        a[i] *= 2LL;
        if (i%2 == 1) {
            first += a[i];
        } else {
            first -= a[i];
        }
    }

    first /= 2;
    vector<ll> ans;
    ans.push_back(first);

    for (int i=1; i<n; i++) {
        ll tmp = a[i] - ans.back();
        ans.push_back(tmp);
    }

    for (auto z: ans) cout << z << " ";


    return 0;
}


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

using namespace std;

int main() {
	string word;
	cin >> word;
	string ans = "No";
	int N = word.length();
	// check if palindrome
	string word_rev = word;
	reverse(word_rev.begin(), word_rev.end());
	if (word_rev == word) {
		string w1 = word.substr(0, (N-1)/2);
		string w1_rev = w1;
		reverse(w1_rev.begin(), w1_rev.end());

		const int start = (N+1)/2;	
	
		string w2 = word.substr(start, (N-1)/2);

		string w2_rev = w2;
		reverse(w2.begin(), w2.end());

		if ((w1 == w1_rev) && (w2 == w2_rev)) {
			ans = "Yes";
		}
	}else{
		ans = "No";
	}
	cout << ans << "\n";
        return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


int main()
{
	ll h, w;
	cin >> h >> w;

	for (ll i = 0; i < h + 2; i++)
	{
		if (i == 0 || i == h + 1)
		{
			for (ll j = 0; j < w + 2; j++)
			{
				print("#");
			}
			println("");
		}
		else
		{
			string s;
			cin >> s;

			println("#" << s << "#");
		}
	}
}

Measured memory_bytes: 3620
# coding: UTF-8
import sys
import numpy as np



n,k = map(int, input().split())
ansList = [False for _ in range(n+1)]

for _ in range(k):
	input()
	tmpList = list(map(int, input().split()))
	for person in tmpList:
		ansList[person] = True

print(ansList.count(False) - 1)

Measured memory_bytes: 27012
#include <stdio.h>

int main() {
  int age;
  scanf("%d", &age);
  if(age == 1) {
    printf("Hello World\n");
  } else {
    int number_a, number_b;
    scanf("%d %d", &number_a, &number_b);
    printf("%d\n", number_a + number_b);
  }
  return 0;
}


Measured memory_bytes: 128
import java.io.*;

public class Main {
    public static void main (String[] args) {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        String str;

        try {
            str = br.readLine();

            if (str.indexOf("9") == -1) {
                System.out.println("No");
            } else {
                System.out.println("Yes");
            }
        } catch (IOException e) {
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 23124
// AOJ 1587: Plants
// 2017.10.23 bal4u@uu

#include <stdio.h>
#include <string.h>

int hi[51][51];

int main() 
{
	int w, h, t, p, x, y, v, ans;

	scanf("%d%d%d%d", &w, &h, &t, &p);
	while (p-- > 0) {
		scanf("%d%d%d", &x, &y, &v);
		hi[x][y]++;
	}
	ans = 0;
	for (y = 0; y < h; y++) for (x = 0; x < w; x++) {
		scanf("%d", &v);
		if (v) ans += hi[x][y];
	}
	printf("%d\n", ans);
	return 0; 
}

Measured memory_bytes: 1796
// agrawal117
//chahat
#include <bits/stdc++.h> 
using namespace std; 
int comp(const void* a, const void* b) 
{ return *(int*)a > *(int*)b ; } 

int findNumberOfTriangles(int arr[], int n) 
{ 
	qsort(arr, n, sizeof( arr[0] ), comp); 

	int count = 0; 

	for (int i = 0; i < n - 2; ++i) 
	{ 
		int k = i + 2; 

		// Fix the second element 
		for (int j = i + 1; j < n; ++j) 
		{ 
			while (k < n && arr[i] + arr[j] > arr[k]) 
			++k; 

			if(k > j) 
			count += k - j - 1; 
		} 
	} 

	return count; 
} 

int main() 
{ 
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++) cin>>arr[i];

	cout<<findNumberOfTriangles( arr, n); 

	return 0; 
} 



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

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

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

template <typename T>
void printArr(const T * arr, int s, int fn) {
    for (int i = s; i <= fn; ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <typename T>
long long minArr(const T * arr, int s, int fn) {
    ll res = 1e16 + 1;
    for (int i = s; i <= fn; ++ i) {
        res = min(res, arr[i]);
    }
    return res;
}

template <typename T>
void printVec(const T * arr) {
    for (int i = 0; i < sz(arr); ++ i) cout << arr[i] << " ";
    cout << '\n';
}

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

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

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();
    
    string s;
    cin >> s;
    
   	if (s[0] == 'S')
   		cout << "Cloudy";
   	if (s[0] == 'C')
   		cout << "Rainy";
   	if (s[0] == 'R')
   		cout << "Sunny";
    
    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define all 100009

int red[all];

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    int num[n+1];
    for (int i = 1; i <= n; i++)
    {
        num[i] = 1;
        red[i] = 0;
    }
    red[1] = 1;
    int x, y;
    for (int i = 0; i < m; i++)
    {
        scanf("%d %d", &x, &y);
        if (red[x] == 1)
        {
            red[y] = 1; //表示一种可能性，只要管可能性增加，不要管减少，注意没有球的时候
        }
        num[x]--;
        num[y]++;
        if (num[x] == 0)
        {
            red[x] = 0;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (red[i] == 1)
        {
            ans++;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  string s;cin >> s;
  bool flag = true;
  for(int i=0;i<s.size();i++){
    if(i&1){
      if(!(s[i]=='L'||s[i]=='U'||s[i]=='D')) flag = false;
    }
    else{
      if(!(s[i]=='R'||s[i]=='U'||s[i]=='D')) flag = false;
    }
  }
  cout << (flag?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 201

int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

void calc(int h,int w){
  char mm[SIZE][SIZE];
  int sy,sx;
  int ans = 0;

  for(int i=0;i<h;i++){
    scanf("%s",mm[i]);

    for(int j=0;j<w;j++){
      if(mm[i][j]=='@'){
	sy = i;
	sx = j;
	mm[i][j]='.';
      }
    }
  }

  queue<pair<int,int> > q;

  q.push({sy,sx});

  while(q.size()){
    int y = q.front().first;
    int x = q.front().second;
    q.pop();

    if(mm[y][x]!='.') continue;
    mm[y][x]='#';
    ans++;

    for(int i=0;i<4;i++){
      if(y+dy[i]<0 || h<=y+dy[i] || x+dx[i]<0 || w<=x+dx[i]) continue;

      if(mm[y+dy[i]][x+dx[i]]=='.'){
	q.push({y+dy[i],x+dx[i]});
      }
    }
  }
  
  printf("%d\n",ans);
}

int main(){
  int h,w;
  
  while(1){
    scanf("%d%d",&w,&h);
    if(h==0) break;
    calc(h,w);
  }
  
  return 0;
}

Measured memory_bytes: 3208
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[])  throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int a = 0;
		String op = "";
		int b = 0;
		boolean end = false;

		while (end == false) {
			String[] tmp = br.readLine().split(" ");
			a = Integer.parseInt(tmp[0]);
			op = tmp[1];
			b = Integer.parseInt(tmp[2]);

			switch (op) {
			case "+":
				System.out.println(a + b);
				break; 
			case "-":
				System.out.println(a - b);
				break;
			case "*":
				System.out.println(a * b);
				break;
			case "/":
				System.out.println(a / b);
				break;
			case "?":
				end = true;
				break;
			default:

			}
		}

	}
}

Measured memory_bytes: 24184
from sys import stdin

if __name__ == '__main__':
    N = int(stdin.readline().rstrip())
    
    AB = []
    for i in range(N):
        AB.append([int(x) for x in stdin.readline().rstrip().split()])
    AB.sort(key=lambda x:x[1])
    
    ans = "Yes"
    sum = 0
    for ab in AB:
        sum += ab[0]
        if sum > ab[1]:
            ans = "No"
            break
    print(ans)

Measured memory_bytes: 84188
#include<iostream>
using namespace std;
int main() {
    int n, v, j;
    cin >> n;
    int A[n];
    for (int i=0; i<n; i++){
        cin >> A[i];
    }
    for (int i=0; i<n; i++){
        if (i == n-1){
            cout << A[i] << endl;
        } else {
            cout << A[i] << " ";
        }
    }
    for (int i=1; i<n; i++){
        v = A[i];
        j = i-1;
        while (j>=0 && A[j]>v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for (int j=0; j<n; j++){
            if (j == n-1){
                cout << A[j] << endl;
            } else {
                cout << A[j] << " ";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3084
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
n = input()


ans = "Good"
for c, d in zip(n, n[1:]):
    # print(c,d)
    if c == d:
        ans = "Bad"

print(ans)

Measured memory_bytes: 38384
import math
import itertools

n = int(input())
mod = 1000000007

def Sign(n):
    if n > 0:
        return 1
    elif n < 0:
        return -1
    else:
        return 0

allZeros = 0
vectors = dict()


def add_positive(_):
    if _ not in vectors:
        vectors[_] = (1, 0)
    else:
        vectors[_] = (vectors[_][0] + 1, vectors[_][1])


def add_negative(_):
    if _ not in vectors:
        vectors[_] = (0, 1)
    else:
        vectors[_] = (vectors[_][0], vectors[_][1] + 1)


for i in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        allZeros += 1
        continue
    gcd = math.gcd(a, b)

    key = (0, 0)
    if a == 0:
        key = (1, 0)
        add_negative(key)
    elif b == 0:
        key = (1, 0)
        add_positive(key)

    elif Sign(a) * Sign(b) > 0:
        key = (abs(a) // gcd, abs(b) // gcd)
        add_positive(key)
    else:
        key = (abs(b) // gcd, abs(a) // gcd)
        add_negative(key)

total = 1
for vec in vectors.values():

    total *= ((2**(vec[0]))
              + (2**(vec[1])) - 1) % mod

print(((total- 1) % mod + allZeros % mod) % mod)

Measured memory_bytes: 120932
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    string S, T;
    cin >> S >> T;
    REP(i,S.length()){
        S = S[S.length()-1] + S.substr(0,S.length()-1);
        if(S == T){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    H, W, A, B = map(int, input().split())
    for _ in range(B):
        ans = "1" * A + "0" * (W-A)
        print(ans)
    for _ in range(H-B):
        ans = "0" * A + "1" * (W-A)
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 40176
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (PrintWriter out = new PrintWriter(System.out); Scanner sc = new Scanner(System.in);) {
			Task task = new Task();
			task.solve(sc, out);
			out.flush();

		} catch (Exception e) {
			// DO NOT USE
		}
	}

	static class Task {
		public void solve(Scanner sc, PrintWriter out) {
			// TODO
			int a = nint(sc);
			int sum = 0;

			if (a < 105) {
				out.print(0);
				return;
			} else if (a == 105) {
				out.print(1);
				return;
			}

			int sumsum = 0;
			for (int f = 105; f <= a; f += 2) {
				sum = 0;
				for (int i = 1; i <= f; i++) {
					if (f % i == 0) {
						sum++;
					}
				}
				if (sum == 8) {
					sumsum++;
				}
			}
			out.print(sumsum);

		}
	}

	// method
	static int nint(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static long nlong(Scanner sc) {
		return Long.parseLong(sc.next());
	}

	static double ndouble(Scanner sc) {
		return Double.parseDouble(sc.next());
	}

	static float nfloat(Scanner sc) {
		return Float.parseFloat(sc.next());
	}

	static String nstr(Scanner sc) {
		return sc.next();
	}

	static long[] longLine(Scanner sc, int size) {
		long[] lLine = new long[size];
		for (int i = 0; i < size; i++) {
			lLine[i] = nlong(sc);
		}
		return lLine;
	}

	static int[] intLine(Scanner sc, int size) {
		int[] iLine = new int[size];
		for (int i = 0; i < size; i++) {
			iLine[i] = nint(sc);
		}
		return iLine;
	}

	static String[] strLine(Scanner sc, int size) {
		String[] strLine = new String[size];
		for (int i = 0; i < size; i++) {
			strLine[i] = nstr(sc);
		}
		return strLine;
	}

	static long maxFromList(List<Long> longList) {
		return longList.stream().max(Comparator.naturalOrder()).get();
	}

	static long minFromList(List<Long> longList) {
		return longList.stream().min(Comparator.naturalOrder()).get();
	}

	public static int sumDigits(int n) {
		int sum = 0;
		while (n != 0) {
			sum += n % 10;
			n /= 10;
		}
		return sum;
	}

	public static long sumDigits(long n) {
		long sum = 0;
		while (n != 0) {
			sum += n % 10;
			n /= 10;
		}
		return sum;
	}

	static List<Integer> getIntegerList(Scanner sc, int size) {
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < size; i++) {
			list.add(nint(sc));
		}
		return list;
	}

	static List<Long> getLongList(Scanner sc, int size) {
		List<Long> list = new ArrayList<>();
		for (int i = 0; i < size; i++) {
			list.add(nlong(sc));
		}
		return list;
	}
}

Measured memory_bytes: 23764
#include<cstdio>
using namespace std;//0:NULL,1:0,2:1,3:00,4:01,5:10,6:11,7:100
const int maxn=300000,MOD=1e9+7,son[8][2]={{1,2},{3,4},{5,6},{1,1},{1,2},{7,2},{6,6},{5,5}};

int n,f[maxn+5][8];char s[maxn+5];

inline void AMOD(int &x,int tem) {if ((x+=tem)>=MOD) x-=MOD;}
int main(){
	scanf("%s",s+1);for (n=1;s[n];n++);n--;f[0][0]=1;
	for (int i=1;i<=n;i++)
		for (int j=0;j<8;j++){
			if (s[i]!='0') AMOD(f[i][son[j][1]],f[i-1][j]);
			if (s[i]!='1') AMOD(f[i][son[j][0]],f[i-1][j]);
		}
	AMOD(f[n][2],f[n][6]);printf("%d\n",f[n][2]);return 0;
}

Measured memory_bytes: 9856
import java.util.Scanner;

public class Main {

	private void doIt() {
		Scanner sc = new Scanner(System.in);
		while(true){
			int e = sc.nextInt();
			if(e == 0)
				break;

			int min = e;
			for(int z = 0; z * z * z <= e; z++){
				for(int y = 0; y *y + z * z * z <= e; y++){
					int x = e - (y *y + z * z * z);
					min = Math.min(min, x + y + z);
				}
			}
			System.out.println(min);
		}


	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}

}

Measured memory_bytes: 12000
#include <iostream>


using namespace std;

int main()
{
	int N, L;
	cin >> N >> L;
	int ans = 0;
	if(L >= 0)
	{
		//select 1
		ans = (N - 1) * L;
		for(int i = 1; i < N; ++i)
		{
			ans += i;
		}
	}
	else if(L > -N)
	{
		//select 1-L
		ans = N * L;
		for(int i = 1; i < N; ++i)
		{
			ans += i;
		}
	}
	else
	{
		//select N-1
		ans = (N - 1) * L;
		for(int i = 1; i < N - 1; ++i)
		{
			ans += i;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main(){

    ll X, A, B;
    cin >> X >> A >> B;

    if(B - A <= X){
        if(A - B >= 0){
            cout << "delicious" << endl;
        }else{
            cout << "safe" << endl;
        }
    }else{
        cout << "dangerous" << endl;  
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    string s;
    cin >> s;
    int i, j, n = s.size();
    int ans = 0;
    for (i = 0, j = n-1; i < j; i++,j--) {
        int ci = 0, cj = 0;
        while (i < n && s[i] == 'x') i++,ci++;
        while (j >= 0 && s[j] == 'x') j--,cj++;
        if (i > j) break;
        if (s[i] != s[j]) {
            puts("-1");
            return 0;
        }
        ans += abs(ci-cj);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
# 整数の入力
h, w = map(int, input().split())
s = [""]*h

for i in range(h):
    s[i] = list(input())

# 探索対象になっている周囲のマス目との添字をあらかじめ記録する
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            continue
        else:
            count = 0
            for d in range(len(dx)):
                x = j + dx[d]
                y = i + dy[d]

                if not 0 <= x < w:
                    continue
                if not 0 <= y < h:
                    continue
                if s[y][x] == "#":
                    count += 1
            s[i][j] = str(count)

for i in range(h):
    print("".join(s[i]))

Measured memory_bytes: 3188
from collections import defaultdict

n = int(input())
nodes = {}
for _ in range(n):
    id_, _k, *c = map(int, input().split())
    nodes[id_] = c
root = set(nodes.keys())
for v in nodes.values():
    root -= set(v)
root = root.pop()
ans = defaultdict(dict)


def solve(id_, depth=0):
    children = nodes[id_]
    type_ = "internal node" if children else "leaf"
    ans[id_].update({"depth": depth, "type": type_, "children": children})
    for child in children:
        ans[child].update({"parent": id_})
        solve(child, depth + 1)


solve(root)
ans[root].update({"parent": -1, "type": "root"})
for k in sorted(ans):
    n = ans[k]
    print(
        "node {}: parent = {}, depth = {}, {}, [{}]".format(
            k,
            n["parent"],
            n["depth"],
            n["type"],
            ", ".join([str(i) for i in n["children"]]),
        )
    )



Measured memory_bytes: 67084
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((int)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

void print(Vl v){
    rep(i, 0, sz(v)){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}

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


int main() {
	ll a, b, c, k; cin >> a >> b >> c >> k;
	if(k <= a) co(k);
	else if(k <= a+b) co(a);
	else co(a-(k-a-b));

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <math.h>
#include <bitset>
#include <queue>


using namespace std;

vector<vector<int> > grid_bfs(vector<string> &s, char start, const string &wall = "#") {
    const int vx[] = {0, 1, 0, -1}, vy[] = {1, 0, -1, 0};
    vector<vector<int> > min_cost(s.size(), vector<int>(s[0].size(), -1));
    queue<pair<int, int> > que;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < s[i].size(); j++) {
            if (s[i][j] == start) {
                que.emplace(i, j);
                min_cost[i][j] = 0;
            }
        }
    }
    while (!que.empty()) {
        auto p = que.front();
        que.pop();
        for (int i = 0; i < 4; i++) {
            int ny = p.first + vy[i], nx = p.second + vx[i];
            if (nx < 0 || ny < 0 || nx >= s[0].size() || ny >= s.size()) continue;
            if (min_cost[ny][nx] != -1) continue;
            if (wall.find(s[ny][nx]) != string::npos) continue;
            min_cost[ny][nx] = min_cost[p.first][p.second] + 1;
            que.emplace(ny, nx);
        }
    }
    return min_cost;
}

void solve() {
    int h, w;
    cin >> h >> w;
    vector<string> data;
    for (int i = 0; i < h; i++) {
        string tmp;
        cin >> tmp;
        data.push_back(tmp);
    }

    int maxWalk = -1;
    for(int y = 0; y < h; y++){
        for(int x = 0; x < w; x++){
            if(data[y][x] != '#'){
                vector<string> tmpdata = data;
                tmpdata[y].replace(x, 1, "X");
                vector<vector<int>> res = grid_bfs(tmpdata, 'X');
                for(int i = 0; i < h; i++){
                    for(int j = 0; j < w; j++){
                        maxWalk = max(maxWalk, res[i][j]);
                    }
                }
            }
        }
    }

    cout << maxWalk << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
const int N = 100005;
typedef long long LL;
int pre[N], nxt[N * 2], w[N * 2], to[N * 2], cnt = 0;
void addEdge(int x, int y, int v) {
  w[cnt] = v;
  nxt[cnt] = pre[x];
  to[pre[x] = cnt++] = y;
}
LL dep[N];
void dfs(int x, int f) {
  for (int i = pre[x]; ~i; i = nxt[i])
    if (to[i] != f) {
      dep[to[i]] = dep[x] + w[i];
      dfs(to[i], x);
    }
}
int main() {
  memset(pre, -1, sizeof pre);
  int n, x, y, v;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d%d%d", &x, &y, &v);
    addEdge(x, y, v);
    addEdge(y, x, v);
  }
  int q, k;
  scanf("%d%d", &q, &k);
  dep[k] = 0;
  dfs(k, -1);
  while (q--) {
    scanf("%d%d", &x, &y);
    printf("%lld\n", dep[x] + dep[y]);
  }
  return 0;
}


Measured memory_bytes: 9856
//let's do it
 #include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1000000000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define boost1 ios::sync_with_stdio(false);
#define boost2 cin.tie(0);
#define mem(a,val) memset(a,val,sizeof a)
#define endl "\n"
#define maxn 100001

int main()
{
	boost1;boost2;
	ll n,a,b,s,l;
	cin>>n>>a>>b;
	s=a+b+(n-2)*a;
	l=a+b+(n-2)*b;
	cout<<max(0LL,l-s+1);
	return 0;
}


Measured memory_bytes: 256
import re
Sp = input().replace('?','.')
T = input()
flag = 0
for i in range(len(Sp)-len(T),-1,-1):
    if re.match(Sp[i:i+len(T)],T):
        Sp = Sp[:i]+T+Sp[i+len(T):]
        flag = 1
        break
if flag == 1:
    print(Sp.replace('.','a'))
else:
    print('UNRESTORABLE')

Measured memory_bytes: 9808
#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() {
    ll h, w;
    cin >> h >> w;
    if (h == 1 || w == 1)
        cout << 1 << endl;
    else if (h*w % 2 != 0)
        cout << (h*w)/2 + 1 << endl;
    else
        cout << (h*w)/2 << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 998244353

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

from operator import itemgetter

def index_sort(A):
    A_sort = sorted(enumerate(A),key=itemgetter(1))
    index = [a[0] for a in A_sort]
    sorted_A = [a[1] for a in A_sort]
    return index, sorted_A

# 一点更新セグメントツリー
## 更新：１点の値をxに更新する　　クエリ演算：op
## 0-indexed
class SegmentTree:
    def __init__(self,N,default):
        # 演算の定義
        self.op = max
        # 初期化の値
        self.default = default
        self.N0 = 2**(N-1).bit_length()
        self.tree = [self.default]*(2*self.N0)
        
    # k番目の値をxに更新
    def update(self,k,x):
        k += self.N0-1
        self.tree[k] = x
        while k >= 0:
            k = (k-1)//2
            self.tree[k] = self.op(self.tree[2*k+1], self.tree[2*k+2])

    # 区間[l,r]へのクエリ
    def query(self,l,r):
        L = l+self.N0
        R = r+self.N0+1 
        s = self.default
        while L < R:
            if R & 1:
                R -= 1
                s = self.op(s,self.tree[R-1])
            if L & 1:
                s = self.op(s,self.tree[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s

    # k番目の値を取得
    def get(self,k):
        return self.tree[k+self.N0-1]

N = I()
X,D = LIR(N,2)

index,X = index_sort(X)
D = [D[i] for i in index]

# iを選んだときに除かれる右端
end = SegmentTree(N,0)
for i in range(N):
    end.update(i,i)
for i in range(N-1)[::-1]:
    p = bisect_right(X,X[i]+D[i]-1)
    val = end.query(i,p-1)
    end.update(i,val)

# i以降を自由に使って作れる場合の数
dp = [0]*N
dp[N-1] = 2
for i in range(N-1)[::-1]:
    dp[i] = dp[i+1]
    if end.get(i) == N-1:
        dp[i] += 1
    else:
        dp[i] += dp[end.get(i)+1]
    dp[i] %= mod

print(dp[0])

Measured memory_bytes: 119864
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define INF 1000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

string ans = "Yes";

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

	ll N;
	cin >> N;

	vector<ll> a(N);
	rep(i,N){
		cin >> a[i];
	}

	a[0] = max((ll)0,a[0]-1);
	repk(i,1,N){
		if(a[i] < a[i-1]){
			ans = "No";
			break;
		}
		else{
			if(a[i] != a[i-1]){
				a[i]--;
			}
		}

		if(i == N-1) ans = "Yes";
	}
	

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int d;
    while(scanf("%d",&d)==1)
    {
        if(d>=22 && d<=25)
        {
            if(d==25)
            {
                printf("Christmas\n");
            }
            else if(d==24)
            {
                printf("Christmas Eve\n");
            }

            else if(d==23)
            {
                printf("Christmas Eve Eve\n");
            }
            else if(d==22)
            {
                printf("Christmas Eve Eve Eve\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 128
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        long N = nextLong();
        if(N%2 != 0){
            println(0);
            return;
        }

        N /= 2;

        long count = 0;
        long f = 5;
        while(true){
            if(N/f == 0) break;
            count += N/f;
            f *= 5;
        }
        println(count);
    }

    static long a(long n){
        return n < 2L ? 1L : n*a(n-2);
    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
	fasterthanlight;
	int n;
	cin >> n;
	cout << (ceil(n / 1000.0) * 1000 ) -n;
	//cout << "\n\n" << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll MOD=1e9+7 ;
const ll max_n=110;
const ll max_v=100010;
ll dp[max_n][max_v];

// Generated by {{ atcodertools.version }} {{ atcodertools.url }}  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int n;cin>>n;
    ll w;cin>>w;
    ll w_ary[n];
    ll v_ary[n];

    rep(i,n) cin >> w_ary[i] >> v_ary[i];

    // ll dp[n+1][100010];
    rep(j,max_n) rep(i,max_v) dp[j][i]=MOD;
    dp[0][0] = 0;

    REP(i,1,n+1) rep(j,max_v)
    {
        if (j-v_ary[i-1]>=0) dp[i][j] = min(dp[i-1][j], dp[i-1][j-v_ary[i-1]]+w_ary[i-1]);
        else dp[i][j] = dp[i-1][j];
    }
    ll ans = 0;
    rep(i,100010)
    {
        if (dp[n][i] <= w) ans = i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 86144
#include<iostream>
using namespace std;
#define K 1000000000000000000

int main() {
  int N;
  cin >> N;
  
  long long A[N];
  long long ans = 1;
  for(int i=0; i<N; i++){
    cin >> A[i];
    if(A[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  for(int i=0; i<N; i++){
    if(K / ans < A[i] ){
      cout << -1 << endl;
      return 0;
    }
    ans *= A[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4360
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		String S = sc.next();
		String ans="WA";

		if(S.charAt(0)=='A') {
			int count=0;
			int index=0;
			//System.out.println("1");
			for(int i=2; i<=S.length()-2;i++) {
				if(S.charAt(i)=='C') {
					count++;
					index=i;
				}
			}
			if(count==1) {
				//System.out.println("2");
				S=S.substring(1,index)+S.substring(index+1,S.length());
				//System.out.println(S);
				int small=0;
				for(int i=0;i<S.length();i++) {
					if(S.substring(i,i+1).matches("[a-z]")) {
						small++;
					}
				}
				if(small==S.length()) {
					ans="AC";
				}
			}
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

string S;;

void solve(){
    cout << S[0]-'0'+S[1]-'0'+S[2]-'0' << endl;
}

int main(){
    cin >> S;

    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long  n;
	cin>>n;
	long long i,a[n+2]{0},pre[n+2]{0};
	for(i=1;i<=n;i++){
		cin>>a[i];
		pre[i]=pre[i-1]+abs(a[i]-a[i-1]);
	}
	pre[n+1]=pre[n]+abs(a[n]);
	for(i=1;i<=n;i++){
		cout<<pre[i-1]+abs(a[i+1]-a[i-1])+pre[n+1]-pre[i+1]<<"\n";
	}
}

Measured memory_bytes: 5160
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    int cnt = 0;
    while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
        int nextA = (B / 2 + C / 2);
        int nextB = (C / 2 + A / 2);
        int nextC = (A / 2 + B / 2);
        if(nextA == A && nextB == B && nextC == C) {
            cout << -1 << endl;
            return 0;
        }
        A = nextA, B = nextB, C = nextC;
        cnt++;
    }
    cout <<cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
const int N=1e5+10;
int h[N],e[N*4],ne[4*N],idx;
void add(int a,int b){
    e[idx]=b,ne[idx]=h[a],h[a]=idx++;
}
bool st[N];
int q[N];
int ans[N];
int cnt=0;
void bfs(int root){
    int hh=0,tt=-1;
    q[++tt]=root;
    st[root]=true;
    cnt++;
    while(hh<=tt){
        int t=q[hh++];
        for(int i=h[t];i!=-1;i=ne[i]){
            int j=e[i];
            if(st[j]){continue;}
            st[j]=true;
            ans[j]=t;
            q[++tt]=j;
            // cout<<tt<<' '<<j<<endl;
            cnt++;
        }
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    memset(h,-1,sizeof h);
    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        add(a,b);add(b,a);
    }
    bfs(1);
    // cout<<cnt<<endl;
    if(cnt==n){
        cout<<"Yes"<<endl;
        for(int i=2;i<=n;i++)cout<<ans[i]<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 7940
def main():
    from math import hypot
    import sys
    input = sys.stdin.readline

    inf = 1 << 60

    xs, ys, xt, yt = map(int, input().split())
    N = int(input())

    def dist(p1, p2):
        d = hypot(p1[0] - p2[0], p1[1] - p2[1])
        return max(0, d - (p1[2] + p2[2]))

    ps = [(xs, ys, 0)]
    ps += (tuple(map(int, input().split())) for _ in range(N))
    ps += [(xt, yt, 0)]

    adj = [[inf] * (N + 2) for _ in range(N + 2)]

    for i, p1 in enumerate(ps):
        for j, p2 in enumerate(ps):
            if i <= j: break  # 自己辺なし
            adj[i][j] = adj[j][i] = dist(p1, p2)

    def dijkstra(s):
        dist = [inf] * (N + 2)
        dist[s] = 0
        det = [0] * (N + 2)

        c, v = 0, s
        det[s] = 1
        while True:
            for u, dc in enumerate(adj[v]):
                nc = c + dc
                if dist[u] <= nc: continue
                dist[u] = nc

            c, v = -1, -1
            for u, d in enumerate(dist):
                if det[u]: continue
                if ~v and c <= d: continue
                c, v = d, u
            if not (~v): break
            det[v] = 1

        return dist

    print(dijkstra(s=0)[N + 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 23924
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#include <bitset>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1e9+7
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for(int i=0;i<n;i++) cin >> A[i];
    ll ans=0;
    for(int i=1;i<n;i++){
        if(A[i]<A[i-1]){
            int num=A[i-1]-A[i];
            ans+=num;
            A[i]+=num;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
from collections import deque
n=int(input())
A=[[0]*3 for i in range(n-1)]
B=[[[] for j in range(2)] for i in range(n)]
for i in range(n-1):
  A[i]=list(map(int,input().split()))
  B[A[i][0]-1][0].append(A[i][1]-1)
  B[A[i][0]-1][1].append(A[i][2])
  B[A[i][1]-1][0].append(A[i][0]-1)
  B[A[i][1]-1][1].append(A[i][2])
d=[0]*n
q,k=map(int,input().split())
C=deque([])
C.append(k-1)
E=[0]*n
E[k-1]=1
while len(C)>0:
  a=C[0]
  C.popleft()
  for i in range(len(B[a][0])):
    if E[B[a][0][i]]==0:
      C.append(B[a][0][i])
      d[B[a][0][i]]=d[a]+B[a][1][i]
      E[B[a][0][i]]=1
for i in range(q):
  s,t=map(int,input().split())
  print(d[s-1]+d[t-1])

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(void){

    string s, t;
    cin >> s >> t;

    int ans = 0;
    rep(i, s.length()){
        if(s[i] != t[i]){
            ans ++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	int n;
	cin >> n;
	if(n >= 1000) cout << "ABD" << endl;
	else cout << "ABC" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main() {
    int N; cin >> N;
 
    map<int, int> m;
    for(int a = 1; a <= N; a++){
        int n = a;
        for(int i=2; i*i<=n; i++){
            if(n % i == 0) {
                while(n % i == 0){
                    m[i]++;
                    n /= i;
                }
            }
        }
        if(n != 1) m[n]++;
    }
    int ans = 1;
    for(auto x : m){
        ans *= (x.second + 1);
        ans %= MOD;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,k;
   cin >>a>>b>>k;
   vector<int> v;
   int i;
   for(i=a;i<a+k&&i<=b;i++){
       v.push_back(i);
   }
   int last = v[v.size()-1];

   for(int j=b;j>last&&k!=0;j--,k--){
      v.push_back(j);
   }
   sort(v.begin(),v.end());
   for(int i=0;i<v.size();i++){
      cout <<v[i]<<endl;
   }

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

ans=defaultdict(int)
d=defaultdict(int)
p_list=[2]

p=2
n=10**5

while p<=n:
    m=2*p
    while m<=n:
        d[m]=1
        m+=p
    p+=1
    while d[p]!=0:
        p+=1
        if p>n:
            break
    p_list.append(p)

pp=defaultdict(int)

for i in p_list:
    if d[(i+1)//2]==0:
        pp[i]=1

cnt=0
for i in range(1,10**5+1,2):
    if pp[i]==1:
        cnt+=1
    ans[i]=cnt

Q=int(input())
for i in range(Q):
    l,r=map(int,input().split())
    print(ans[r]-ans[l-2])


Measured memory_bytes: 71172
function main(input) {
  const formatted_input = input.split('\n');

  const before = formatted_input[0].split('');
  const after = formatted_input[1].split('');

  var before_hash = {};
  for(var elem of before){
    before_hash[elem] = new Array;
  }

  var after_hash = {};
  for(var elem of after){
    after_hash[elem] = new Array;
  }

  
  var i=0
  for( var elem of before ){
    var arr = before_hash[elem];
    arr.push(i);
    before_hash[elem] = arr;
    i++;
  }

  var i=0
  for( var elem of after ){
    var arr = after_hash[elem];
    arr.push(i);
    after_hash[elem] = arr;
    i++;
  }

 before_arr = []
 for(var elem in before_hash){
   var arr = before_hash[elem];
   for(var i=0; i < arr.length ; i++ ){
     before_arr.push(arr[i]);
   }
    before_arr.push('|');
 }

  after_arr = []
  for(var elem in after_hash){
    var arr = after_hash[elem];
    for(var i=0; i < arr.length ; i++ ){
      after_arr.push(arr[i]);
    }
    after_arr.push('|');
  }

  //console.log(before_hash);
  //console.log(after_hash);
  //console.log(before_arr);
  //console.log(after_arr);
  
  if(after_arr.toString()==before_arr.toString()){
    console.log('Yes');
  }else{
    console.log('No');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
// 01:34:40 > 




Measured memory_bytes: 77844
package main

import "fmt"

func scanIntSlice(N int) []int {
	_slice := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&_slice[i])
	}
	return _slice
}
func main()  {
	A := scanIntSlice(4)
	R := A[0]
	G := A[1]
	B := A[2]
	N := A[3]
	ans := 0
	for r:=0;r<=N/R;r++{
		for g:=0;g<=N/G ;g++ {
			tmp_last:= N- r*R - g*G
			if tmp_last < 0{
				break
			}
			if tmp_last%B ==0{
				ans++
			}

		}
	}
	fmt.Println(ans)

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n,k,sum; cin>>n>>k; vector<int> v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  sort(v.begin(),v.end());  sum=0;
  for(int i=0;i<k;i++) sum+=v[i];
  cout<<sum;
  return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException{
		int n, b,f,r,v;
		String[] list;
		int[][][] building;
		StringBuilder builder = new StringBuilder();

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(br.readLine());
		building = new int[4][3][10];
		for(int i=0; i<n; i++){
			list = br.readLine().split(" ");
			b = Integer.parseInt(list[0]);
			f = Integer.parseInt(list[1]);
			r = Integer.parseInt(list[2]);
			v = Integer.parseInt(list[3]);
			building[b - 1][f - 1][r - 1] += v;
		}
		for(int i = 0; i < 4; i++){
			if(i != 0)builder.append("####################\n");
			for(int j = 0; j < 3; j++){
				for(int k = 0; k < 10; k++){
					builder.append(" " + building[i][j][k]);
				}
				builder.append("\n");
			}
		}
		builder.delete(builder.length() -1 , builder.length());
		System.out.println(builder);
		br.close();
	}
}

Measured memory_bytes: 24628
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from collections import defaultdict
#d = defaultdict(int)
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import numpy as np
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
s = p[:X]+q[:Y]+r
n = len(s)
for i in range(n):
    s[i] *= -1
heapify(s)
ans = 0
for i in range(X+Y):
    ans -= heappop(s)
print(ans)

Measured memory_bytes: 38860